Wednesday, December 8, 2021

How to make text field read only in LWC and AURA

This post explains how to make text field read only in LWC and AURA salesforce. To make the field read only in lightning there are two ways :

  • readonly="true"
  • disabled = "true"

readOnly.html(LWC):

<template>
    <div style="padding-left:100px; width:300px;">
        <lightning-input type="text" label="This is read only field" value="Read only field" readonly/>
    </div>
    <div style="padding-left:100px; width:300px;">
        <lightning-input type="text" label="This is read only field" value="Read only field" disabled="true"/>
    </div>
</template>

readOnly.cmp(AURA):

<aura:component >
    <div style="padding-left:100px; width:300px;">
        <lightning:input type="text" readonly="true" value="Read only field" label="This is read only field" />
    </div>
    <div style="padding-left:100px; width:300px;">
        <lightning:input type="text" disabled="true" value="Read only field" label="This is read only field" />
    </div>
</aura:component>


OUTPUT :

How to make text field read only in LWC and AURA

Thanks, 
Lovesalesforceyes


No comments:

Post a Comment

Get selected radio button value in LWC

This post explains how to get selected radio button in LWC. Below is demo of output : To use the radio button in LWC you have to use the  li...