gpt4 book ai didi

javascript - 多页 jQuery 表单未提交

转载 作者:行者123 更新时间:2023-11-28 08:29:57 26 4
gpt4 key购买 nike

这是 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();
}

这是我的 fiddle ,http://jsfiddle.net/bd4T2/我尝试过使用 jquery 验证 js 的多页表单,但表单未提交

最佳答案

好吧,我从 fiddle 中复制了代码(它不起作用,并且不包含 jquery 库),并且我在 Submitform 函数中发现了错误,当您在表单 id 前面有一个哈希值时使用 dom 查找表单:

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();
}

关于javascript - 多页 jQuery 表单未提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21988644/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com