-1

In Lightning Input,it validates email format

Code for Email:

<lightning:input label="Email " value="{!v.account.email}" required="true" type="email"/>

But I have tried below code for phone number,itsnot validating phone number format.We can easily enter text also

<lightning:input label="phone" value="{!v.account.phone}" required="true" type="phone"/>
1

list of available values of type attribute are listed here as examples, and there is no phone type

change type to tel in order to have phone validation, also populate regex pattern as pattern

<lightning:input type="tel" label="phone" value="{!v.account.phone}" required="true" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"/>
2
  • why its not accepting this pattern :12344567891...what kind of format it will accept?..can you please explain the pattern once.This pattern 1234-456-7891? Nov 16 '18 at 10:52
  • @AnnappaPH this regular expression. to read more about it you can check it Nov 16 '18 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.