【发布时间】:2014-02-20 20:12:31
【问题描述】:
这是一个相当基本的调查表;我正在使用 JQuery 根据用户选择有条件地显示/隐藏字段。
//FORM CONDITIONALS Hides all the helpfulness radios and only shows them when "Yes" for a particular question is checked
$("#datainp .occurrence").click(function () {
var nexttd = $(this).next('td');
if ($(this).children("input:first").is(':checked')) {
$(nexttd).show();
$(nexttd).children("input").removeAttr("checked");
} else {
$(nexttd).hide();
}
我也有一个客户端验证功能:。
//Client side validation and submissions
$('#submit').click(function(e) {
e.preventDefault();
var level = $('#Level').val();
var schoolid = $('#school').val();
if (!schoolid) {
alert("Please select a school!");
return;
}
if (!level) {
alert("Please select a grade level!");
return;
}
alert("foo");
$('#frmTeacherEvalGuidance').submit(function() {alert("bar") });
});
除了验证结束时的 .submit() 之外,一切正常(警报验证)。 我的表单条件部分中的某些内容是否与 .submit() 冲突?当我注释掉 javascript 的第一部分时,表单会按预期提交。 JsFiddle 在这里:http://jsfiddle.net/r4Y4g/1/(我知道 html 有点笨拙,但不是我的;更新一个旧的团队项目)
【问题讨论】:
标签: javascript jquery html dom