这是我的密码验证码。
除了空间,我想接受此文本框中的所有内容。这是我的验证码。
$("#clientPassWord").on("change", function() {
var clientPassWord = $("#clientPassWord").val().length;
var clientPassWord1 = $("#clientPassWord").val();
if (clientPassWord == null || clientPassWord <= 0) {
$("#passmsg").show();
$("#passmsg").html("This is a required field. You can’t leave it empty.");
} else {
if (clientPassWord >= 8) {
$("#passmsg").hide();
$("#joinbtn").removeAttr('disabled');
if (clientPassWord1.toLowerCase().match("paperindex") || clientPassWord1.toUpperCase().match("PAPERINDEX") || clientPassWord1.toLowerCase().match("paperindexcom") || clientPassWord1.toUpperCase().match("PAPERINDEXCOM")) {
$("#passmsg").show();
$("#passmsg").html(""PaperIndex" and variations of this word are not allowed here");
} else {
$("#passmsg").hide();
$("#joinbtn").removeAttr('disabled');
}
} else {
$("#passmsg").show();
$("#passmsg").html("Short passwords are easy to guess. Enter at least 8 characters.");
$("#joinbtn").attr('disabled', 'disabled');
}
}
});
答案 0 :(得分:0)
您只需检查文本框值中是否存在空格('')。
$("#clientPassWord").on("change", function () {
var clientPassWord=$("#clientPassWord").val().length;
var clientPassWord1=$("#clientPassWord").val();
if(clientPassWord==null || clientPassWord<=0){
$("#passmsg").show();
$("#passmsg").html("This is a required field. You can’t leave it empty.");
}
else if($("#clientPassWord").val().indexOf(' ') >= 0){
$("#passmsg").show();
$("#passmsg").html("Spaces are not allowed!!!");
}
else{
if(clientPassWord>=8 ) {
$("#passmsg").hide();
$("#joinbtn").removeAttr('disabled');
if (clientPassWord1.toLowerCase().match("paperindex") || clientPassWord1.toUpperCase().match("PAPERINDEX") || clientPassWord1.toLowerCase().match("paperindexcom") || clientPassWord1.toUpperCase().match("PAPERINDEXCOM") ) {
$("#passmsg").show();
$("#passmsg").html(""PaperIndex" and variations of this word are not allowed here");
}
else{
$("#passmsg").hide();
$("#joinbtn").removeAttr('disabled');
}
}
else {
$("#passmsg").show();
$("#passmsg").html("Short passwords are easy to guess. Enter at least 8 characters.");
$("#joinbtn").attr('disabled', 'disabled');
}
}
});