I used jquery validation plugin to validate my form but in one text box I want to validate the NIC(National Identity Card) number of our country .I got the regular expression for NIC number can anyone tell me how to add additional method to validate this .
reqular expression for NIC number : /^[0-9]{9}[vVxX]$/
textbox id : showNic
here is my jQuery code...
$(document).ready(function () {
jQuery.validator.setDefaults({
// where to display the error relative to the element
errorPlacement: function (error, element) {
error.appendTo(element.parent().find('div.myErrors'));
}
});
$('#basicDetails').validate({ // initialize the Plugin
rules: {
fname: {
required: true,
lettersonly: true,
},
lname: {
required: true,
lettersonly: true,
},
},
messages: {
fname: {
required: "Please enter your first name",
lettersonly: "Login format not valid",
},
lname: {
required: "Please enter your last name",
lettersonly: "Login format not valid",
},
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
return false; // for demo
}
});
});