我的表格结尾处有这个。我为用户提供了继续访问另一个表单或上传当前表单上的数据的选项。
我的问题是,当我在Chrome,IE,Safari,Android Internet上进行测试时。当您选择任一选项时,一切正常。
<form class="section4form" id="section4form" name="section4" action="" method="post" enctype="multipart/form-data">
<!-- Other sections of my form are here -->
<div class="myclass">
<select id="selector" name="selector">
<option value="">Please choose here to Finish Lead Gen or Continue to Section 5</option>
<option value="http://mydomain/lead5.php">Finish & Upload</option>
<option value="http://mydomain/lead4.php">Continue To Boiler Assessment</option>
</select>
</div>
<button type="submit" class="btn green" id="section4formsubmit" name="section4formsubmit" >Continue</button>
</form>
这是使用表单底部代码的jquery
<script>
document.forms.section4.onsubmit = function (event) {
var e = event || window.event,
form = e.currentTarget || e.sourceElement;
e.preventDefault();
if (form.action === "") return false;
form.action = form.selector.value;
form.submit();
};
</script>
我添加的检查js文件以验证表单
var LeadGen4 = function () {
var handleLeadGen4 = function () {
var form4 = $('#section4form');
var error4 = $('.alert-danger', form4);
var success4 = $('.alert-success', form4);
form4.validate({
errorElement: 'span', //default input error message container
errorClass: 'help-block', // default input error message class
focusInvalid: false, // do not focus the last invalid input
ignore: "",
rules: {
householdersigned: {
required: true
},
hasawgsigned: {
required: true
},
assessordeclaration: {
required: true
},
assessorname: {
minlength: 5,
required: true
},
typeofleadgen: {
required: true
}
},
invalidHandler: function (event, validator) { //display error alert on form submit
error4.show();
App.scrollTo(error4, -200);
},
highlight: function (element) { // hightlight error inputs
$(element)
.closest('.form-group').addClass('has-error'); // set error class to the control group
},
unhighlight: function (element) { // revert the change done by hightlight
$(element)
.closest('.form-group').removeClass('has-error'); // set error class to the control group
},
success: function (label) {
label
.closest('.form-group').removeClass('has-error'); // set success class to the control group
},
submitHandler: function (form) {
$('.section4formsubmit').html(data);
error4.hide();
}
});
}
return {
//main function to initiate the module
init: function () {
handleLeadGen4();
}
};
} ();
我的问题是,如果用户将Firefox作为浏览器,则下面的代码不会执行任何操作。无论选择哪个选项,选择都不会进行。
答案 0 :(得分:1)
评论该线路!这条线是多余的,没有意义。
submitHandler: function (form) {
// >>>>>>>>> $('.section4formsubmit').html(data);
error4.hide();
}