[英]Multi-page jQuery form not submitting
Here is the jQuery code 这是jQuery代码
$("#register-form").submit(function (e) {
e.preventDefault();
}).validate({
rules: {
name: "required",
address: "required",
phone: "required",
landmark: "required",
pincode: "required",
city: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please enter your name",
address: "Please enter your address",
phone: "Please enter your phone",
landmark: "Please enter your landmark",
pincode: "Please enter your pincode",
city: "Please enter your city",
email: "Please enter a valid email address"
},
submitHandler: function (form) {
//form.submit();
//alert("Do some stuff...");
$("#step1").hide();
//$('#step1img').css('opacity','0.5');
//$('#step2img').css('opacity','1');
$("#step2").show();
//submit via ajax
return false;
}
});
// });
$("#back").click(function () {
$("#step1").show();
$("#step2").hide();
});
function submitform() {
document.getElementById('#register-form').submit();
}
this is my fiddle , http://jsfiddle.net/bd4T2/ i have tried multipage form , using jquery validation js , but form is not submitting 这是我的小提琴, http://jsfiddle.net/bd4T2/我尝试过使用jquery验证js的多页表单,但表单未提交
okay, I copied the code out of the fiddle (which wasn't working and did not include the jquery library) and i found the error in the submitform function, you've got a hash in front of the form id when using the dom to find the form: 好的,我从小提琴中复制了代码(这是行不通的,并且不包含jquery库),并且我在Submitform函数中发现了错误,使用dom时,表单id前面有一个哈希查找表格:
function submitform() {
document.getElementById('#register-form').submit(); //<-- '#register-form'
}
//this is not going to work, you were looking to use jquery here
document.getElementById('#register-form').submit();
will not work, because there's no #
in the form id, so it should read like this; 将不起作用,因为表单ID中没有
#
,因此它应如下所示:
function submitform() {
$('#register-form').submit();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.