我在我的网站上做了一个小测验,如果选择了正确的答案,我需要检查表单提交。如果某些必填字段未填写,则不会提交表单,并在测验部分给出错误答案的错误,这是我的脚本;
<script type="text/javascript">// <![CDATA[
$.extend($.validator.messages, {
required: "this is required",
email: "enter valid email"
});
$.validator.addMethod("equalValue", function(value, element, param) {
var elem_name = $(element).attr('name');
value = $('input:radio[name="'+elem_name+'"]:checked').val();
return(value == param);
}, 'Incorrect answear');
$(document).ready(function() {
$("#form").validate({
ignoreTitle: true,
rules: {
gender: "required ",
quiz1: {required: true, equalValue: "A"},
quiz2: {required: true, equalValue: "A"},
quiz3: {required: true, equalValue: "C"},
quiz4: {required: true, equalValue: "B"},
quiz5: {required: true, equalValue: "C"},
quiz6: {required: true, equalValue: "B"},
}
});
});
// ]]></script>
如果它返回false,我该怎么做,它不会让表单提交?
提前致谢