JQuery NIC Support

I need a regular expression to validate the Pakistan National Identification Card (NIC), which contains numbers and dashes in the format below

12345-1234567-1

Please, help..

+4
source share
5 answers

you can use standard javaScript to test the regex expression:

 var idToTest = '12345-1234567-1', myRegExp = new RegExp(/\d{5}-\d{7}-\d/); if(myRegExp.test(idToTest)) { //if true } else { //if false } 
+8
source

Try the following:

 var cnic_no = '12345-1234567-9', var cnic_no_regex = /^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$/; if(cnic_no_regex.test(cnic_no)) { alert('Right'); } else { alert('Wrong'); } 

JsFiddle: https://jsfiddle.net/k81w2x77/1/

JsFiddle: https://jsfiddle.net/fokq2woq/10/

+4
source

This will confirm it. (For now, the format will be exactly as you declare)

\d{5}-\d{7}-\d

+1
source

it should be like

 myRegExp = new RegExp(/\d{5}-\d{7}-\d{1}$/); 
+1
source

You can use this regular expression to check CNIC

 ^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$ 

to see how to use it in a jquery function, see this example .

0
source

All Articles