Javascript Tutorial to Validate 12 Digit Aadhaar Card Number Using Regular Expression in Browser Full Project For Beginners

 

 

index.html

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Validate 12 Digit Aadhaar Card Number in Javascript</title>
</head>
<body>
    <input type="text" id="txtAadhar" onblur="AadharValidate();" />

<hr />
<input type="button" id="btnSubmit" value="Submit" onclick="ValidatePAN()" />  
</body>
<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>
</html>

Leave a Reply