Javascript: Regular expression for Mobile Number, Aadhar Number and PAN Number
Hi this is Khamroddin Shaikh, react native developer from Firstcry.com.
In this story, we are going to learn how to create regular expression for Mobile number, Aadhar number and PAN number in javascript (ECMA6).
- Mobile Number: It is a unique contact number, which consist of only 10 numerical digits and no alphabets/ special character symbols.
ex: 1234567890
Regular expression for Mobile number in javascript
const mobileNumber = 1234567890
regEx = /^[0–9]{10}$/;
result = regEx.test(mobileNumber)
2. Aadhar Number: It is Unique Identification number in India for every citizen. It also contains only integers consisting length of 12 digits. No alphabets/ special characters allowed.
Get Shaikh Khamaroddin’s stories in your inbox
Join Medium for free to get updates from this writer.
ex:123456789012
const AadharNumber= 123456789012
regEx = /^[0–9]{12}$/;
result = regEx.test(AadharNumber)
3. PAN number: Permanent Account Number used for official purpose. It contains alphanumerical characters and no special characters allowed. First five characters are capital alphabets, then 4 digits and last character is capital alphabet.
ex : ABCDE1234F
const PANNumber= ABCDE1234F
regEx = /^[A-Z]{5}[0–9]{4}[A-Z]{1}$/;
result = regEx.test(AadharNumber)
In all above examples, result will contain Boolean value true or false based on provided input. If you have any queries please comment below regarding above examples. Thank you.




