这是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();
}
这是我的小提琴,http://jsfiddle.net/bd4T2/我尝试了多页形式,使用jquery验证js,但表单没有提交
答案 0 :(得分:0)
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();
不起作用,因为表单ID中没有#
,所以它应该是这样的;
function submitform() {
$('#register-form').submit();
}