+ Start a Discussion
CrmEditrCrmEditr 

make a non required field to be required in salesforce lighting web component

I would like to create lwc wherein I want to make some non- required fields as required whenever user does not enter a value. May be display with message or flag a lable.
VinayVinay (Salesforce Developers) 
You can use lightning-input-field to make field required.

Check below references.

https://developer.salesforce.com/docs/component-library/bundle/lightning-input-field/specification
http://ways2salesforce.com/index.php/2020/08/12/validate-fields-on-ui-in-lwc/

Thanks,
Ashish Kumar YadavAshish Kumar Yadav
Hi CrmEditr,

add required="true" in your markup for input field.

<aura:component >
    <aura:attribute name="EmpName" type="String" default='' />
    <lightning:input label="Employee Name" value="{!v.EmpName}" required="true"/>
</aura:component>

If it is work for you please mark as the best answer.if you face any problem let me know.