Pan validation in javascript
Javascript Code
<script>
$("#pan_no").keypress(function(e){
var charCode = e.which;
var name = $("#pan_no").val();
/*
8 - (backspace)
32 - (space)
48-57 - (0-9)Numbers
*/
if (name.length <= 4)
{
if(!(charCode >= 65 && charCode <= 90) && !(charCode >= 97 && charCode <= 122) && (charCode != 32 && charCode != 8) && !(charCode == 9)) {
return false;
}
}
if (name.length > 4 && name.length < 9)
{
if((charCode != 8 || charCode ==32 ) && (charCode < 48 || charCode > 57)) {
return false;
}
}
if (name.length == 9)
{
if(!(charCode >= 65 && charCode <= 90) && !(charCode >= 97 && charCode <= 122) && (charCode != 32 && charCode != 8) && !(charCode == 9)) {
return false;
}
}
if(name.length > 9){
return false;
}
});
</script>
0 Comments