Javascript fom验证不起作用(仅术语)
此代码正在运行,但术语不起作用,因为我不理解如何使用术语和条件的复选框 我不明白如何使用此代码有效的条款和条件复选框,但条款无效,因为Javascript fom验证不起作用(仅术语),javascript,Javascript,此代码正在运行,但术语不起作用,因为我不理解如何使用术语和条件的复选框 我不明白如何使用此代码有效的条款和条件复选框,但条款无效,因为 $(document).ready(function () { $("#register").submit(function () { var x = $('#email').val(); var atpos = x.indexOf("@"); var dotpos = x.lastIndexOf("."); var pass
$(document).ready(function () {
$("#register").submit(function () {
var x = $('#email').val();
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
var passw = $('#password').val();
var repassw = $('#repassword').val();
if ($('#email').val() == "") {
$('#email_error').html("Please Enter Email");
return false;
}
if ($('#password').val() == "") {
$('#email_error').html("");
$('#password_error').html("Please Enter Password");
return false;
} else if ($('#repassword').val() == "") {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("Please Re Enter Password");
return false;
} else if (passw != repassw) {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("");
$('#repassword_error').html("Please Re Enter Same Password");
return false;
} else if ($('#city').val() == '0') {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("");
$('#repassword_error').html("");
$('#city_error').html("Please Choose your City");
return false;
} else if ($('#city').val() == '0') {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("");
$('#repassword_error').html("");
$('#city_error').html("Please Choose your City");
return false;
} else if ($('#terms').val() = !checkbox.checked) {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("");
$('#repassword_error').html("");
$('#city_error').html("");
$('#terms').html("hello");
return false;
} else if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= x.length) {
$('#email_error').html("");
$('#password_error').html("");
$('#repassword_error').html("");
return false;
}
});
});
您可以通过多种方式检查复选框是否选中
if($("#checkBoxId").is(':checked') == false){
alert("not checked");
}
二,
等等。请重新表述您的问题。。。就像和尤达说话一样
if($("#checkBoxId").prop('checked') == false ){
alert("not checked");
}