Introduction
This post shows the code to validate a PAN number. Here is the Javascript code, just add the class "pan" in a text control.
PAN no. sample: ABCDE1234F
Code
- <script type="text/javascript">
- $(document).ready(function(){
-
- $(".pan").change(function () {
- var inputvalues = $(this).val();
- var regex = /[A-Z]{5}[0-9]{4}[A-Z]{1}$/;
- if(!regex.test(inputvalues)){
- $(".pan").val("");
- alert("invalid PAN no");
- return regex.test(inputvalues);
- }
- });
-
- });
- </script>
-
- PAN : <input type="text" class="pan">