how to Validate Aadhaar Card Number in Javascript? – aadhaar card number validation

Today, We want to share with you aadhaar card number validation in javascript.In this post we will show you aadhar card validation in javascript, hear for adhaar number validation (verhoeff algorithm) we will give you demo and example for implement.In this post, we will learn about
10 digit mobile number validation using javascript
with an example.

how to Validate Aadhaar Card Number in Javascript?

first of all We Know that goverment Aadhaar Card has total 12-digits Numbers.
example like:

Aadhaar Card Number :

78XX 45XX 97XX
75XX 46XX 96XX
72XX 47XX 95XX
76XX 48XX 94XX

The valid Aadhar number must satisfy the bellow some conditions:

  1. Aadhaar Card has total 12 digits.
  2. not start with 0 & 1.
  3. not contain any alphabet & special characters.
  4. white space after every 4 digits.
Read Also:  jQuery Delete Confirm in Laravel 5.7 Example

REGULAR EXPRESSION

var regexp=/^[2-9]{1}[0-9]{3}\s{1}[0-9]{4}\s{1}[0-9]{4}$/;

<script> 
   function validation()
       {   
            
            var regexp=/^[2-9]{1}[0-9]{3}\s{1}[0-9]{4}\s{1}[0-9]{4}$/;
           
            var x=document.getElementById("txtAadhar").value;
			if(regexp.test(x)) {
			   window.alert("Good Luck, Your Valid Aadhar no.");   
			}
			else { 
				window.alert("Sorry, Invalid Aadhar no.");
			}
   </script>

12 or 16 Digit Aadhar Number Validation using JavaScript

<input type="text" id="txtAadhar" onblur="AadharValidate();" />
<script type="text/javascript">
    function AadharValidate() {
        var aadhar = document.getElementById("txtAadhar").value;
        var adharcardTwelveDigit = /^\d{12}$/;
        var adharSixteenDigit = /^\d{16}$/;
        if (aadhar != '') {
            if (aadhar.match(adharcardTwelveDigit)) {
                return true;
            }
            else if (aadhar.match(adharSixteenDigit)) {
                return true;
            }
            else {
                alert("Enter valid Aadhar Number");
                return false;
            }
        }
    }
</script>

I hope you get an idea about Aadhaar Card Number Validation Using Javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.