function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.