Adding a red asterisk to required fields using label in LWC

I am trying to add a double or single asterisk to lightning: input tags in LWC, by using "required" tag inside the tag I am able to see the asterisk, but two issues with this are I have to show a red asterisk to some conditionally mandatory issues.

Solution - 

You can use label-hidden variant and put a label.

<template>
    <label>Middle Name</label>
    <abbr title="required" class="slds-required">**</abbr>
    <lightning-input label="Middle Name" variant="label-hidden" aria-required="true" maxlength="80"></lightning-input>
</template>



Comments

Popular posts from this blog

The Developer Console didn't set the DEVELOPER_LOG trace flag on your user. Having an active trace flag triggers debug logging. You have 1,978 MB of the maximum 1,000 MB of debug logs. Before you can edit trace flags, delete some debug logs.

Salesforce: Serial and Parallel Approval