function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
LWC <lightning-input type="text" maxlength="10" onblur={formatPhoneNumber} value={PhnValue} name="Phone"> </lightning-input> JS formatPhoneNumber(event){ var phoneNumber = event.target.value; var s = (""+phoneNumber).replace(/\D/g, ''); var m = s.match(/^(\d{3})(\d{3})(\d{4})$/); var formattedPhone = (!m) ? null : m[1] + "-" + m[2] + "-" + m[3]; this.PhnValue=formattedPhone; } --------------------------------------------------------- AURA <lightning:input type="text" maxlength="10" onblur = "{!c.formatPhoneNumber}" aura:id="Phone" label="Phone" name="Phone"/> Controller formatPhoneNumber: function(component, helper, event) { var phoneNo = component.find("Phone"); var phoneNumber = phoneNo.get('v.value'); var s = (""+phoneNumber).replace(/\D/g, ''); var m = s.match(/^(\d{3})(\d{3})(\d{4})$/); var formattedPhone = (!m) ? null : m[1] + "-" + m[2] + "-" + m[3]; phoneNo.set('v.value',formattedPhone); }
Hi Priya
Try this :
<template> <lightning-input type="tel" label="Telephone" value="343-343-3434" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"> </lightning-input> </template>
Please mark it as Best Answer, if it helps.
Thanks
<aura:component> <lightning:input type="tel" label="Phone field with pattern matching" name="phone3" value="123-123-1234" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"/> </aura:component>
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
Hi Priya
Try this :
Please mark it as Best Answer, if it helps.
Thanks
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
Please use this Tested code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh