私は JavaScript 検証コードを持っています。; 、 ` :
これまでの私のコード:
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>"
}
});
});
ユーザー名ルールで防止したい。そのため、などを入力. , ;
すると、許可できないというメッセージが表示されます。