October 23, 2020

How to restrict users to avoid entering characters other than alphabets and number in Salesforce Lightning Web Component?

Sample Code:
<template>
    <div class="slds-box slds-theme--default">
        <lightning-input
                        type="text"
                        label="String Only"
                        pattern="[a-zA-z0-9]+"
                        message-when-pattern-mismatch="Special Characters not allowed">
        </lightning-input>
    </div>
</template>

Output:



No comments:

Post a Comment