I have javascript validation code, now I want to prevent . ; , ` :
this my code so far :
jQuery.validator.addMethod("noSpace", function(value, element) {
return !value.match(/\s/g);
});
$().ready(function() {
$("#signup_form").validate( {
rules: {
full_name: "required",
username: {
required: true,
minlength: 2,
noSpace: true,
},
password: {
required: true,
minlength: 5
},
email: {
required: true,
email: true
},
},
messages: {
full_name: "<div class='spacing'>Please enter your full name</div>",
username:
{
required: "<div class='spacing'>Please enter an username</div>",
minlength: "<div class='spacing'>Your username must consist of at least 2 characters</div>",
noSpace: "<div class='spacing'>No space allowed</div>",
},
password:
{
required: "<div class='spacing'>Please provide a password</div>",
minlength: "<div class='spacing'>Your password must be at least 5 characters long</div>"
},
email: "<div class='spacing'>Please enter a valid email address</div>"
}
});
});
I want to prevent in username rules. So if I input . , ;
etc, it will show message that it can't allowed.