Php 密码不匹配时禁用表单提交按钮
我试图找出应该在哪里包含一个js代码,当密码不匹配时,我会禁用表单提交按钮 html: 也许我把$(“#btnSignUp”).prop(“disabled”,true)放错地方了;代码?试试看Php 密码不匹配时禁用表单提交按钮,php,javascript,Php,Javascript,我试图找出应该在哪里包含一个js代码,当密码不匹配时,我会禁用表单提交按钮 html: 也许我把$(“#btnSignUp”).prop(“disabled”,true)放错地方了;代码?试试看 $("#btnSignUp").attr("disabled", "disabled"); 这应该行得通 if (this.field1.value != "" && this.field1.value == this.field2.value) { r.innerHTML = th
$("#btnSignUp").attr("disabled", "disabled");
这应该行得通
if (this.field1.value != "" && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
$("#btnSignUp").removeAttr("disabled");
} else {
r.innerHTML = this.nomatch_html;
$("#btnSignUp").attr("disabled", "disabled");
}
既然您使用的是jQuery,为什么您需要为不支持
getElementById
的浏览器提供自己的保护?
function verifynotify(field1, field2, result_id, match_html, nomatch_html) {
this.field1 = field1;
this.field2 = field2;
this.result_id = result_id;
this.match_html = match_html;
this.nomatch_html = nomatch_html;
this.check = function() {
// Make sure we don't cause an error
// for browsers that do not support getElementById
if (!this.result_id) { return false; }
if (!document.getElementById){ return false; }
r = document.getElementById(this.result_id);
if (!r){ return false; }
if (this.field1.value != "" && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
$("#btnSignUp").prop("disabled", false);
} else {
r.innerHTML = this.nomatch_html;
$("#btnSignUp").prop("disabled", true);
}
}
}
$("#btnSignUp").attr("disabled", "disabled");
if (this.field1.value != "" && this.field1.value == this.field2.value) {
r.innerHTML = this.match_html;
$("#btnSignUp").removeAttr("disabled");
} else {
r.innerHTML = this.nomatch_html;
$("#btnSignUp").attr("disabled", "disabled");
}