I'm using following rules to validate the username using jQuery validation method. I want to add another rule that username should contain only alphanumeric and underscore character. How can i add additional method for that rule. Is it possible that if user gives less than 4 characters, then I print the minimum length error message, and if the user gives invalid characters, then I give the invalid character error message? Thanks.
$(document).ready(function() {
$("#sform").validate({
rules: {
username: {
required: true,
minlength: 4
}
},
messages: {
username: "Minimum length 4.",
}
});
});