我还没有看到有人问过这个问题--尽管我读了大约100个关于类似主题的jQuery步骤--似乎没有一个能解决我的问题。
我正在使用jQuery- step,并希望在第一步完成后添加一个"reset“按钮-以防我的用户想要清除表单并重新开始。我希望这个按钮是在默认的“下一步”按钮之后。
这是我当前基于默认基本表单here的脚本
$(function ()
{
function errorPlacement(error, element)
{
element.before(error);
}
$("#form").validate({
rules: {
zip: {
required: true,
maxlength:5,
minlength:5
},
phone: {
required: true,
minlength: 10,
phoneUS: true
}
}
});
$("#wizard").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
onStepChanging: function (event, currentIndex, newIndex)
{
// Allways allow step back to the previous step even if the current step is not valid!
if (currentIndex > newIndex)
{
return false;
}
$("#form").validate().settings.ignore = ":disabled,:hidden";
return $("#form").valid();
},
onFinishing: function (event, currentIndex)
{
$("#form").validate().settings.ignore = ":disabled";
return $("#form").valid();
},
onFinished: function (event, currentIndex)
{
alert("Thank you! Your request has been sumbitted.");
}
});
});发布于 2014-07-15 15:15:16
您可以启用并使用cancel按钮来调用validator.resetForm()。请参见以下示例:
$(function ()
{
var validator;
$("#wizard").steps({
enableCancelButton: true,
onCanceled: function (event)
{
validator.resetForm();
}
});
validator = $("#form").validate({
rules: {
zip: {
required: true,
maxlength:5,
minlength:5
},
phone: {
required: true,
minlength: 10,
phoneUS: true
}
}
});
});发布于 2017-02-01 19:22:59
$form.find("[aria-label=Pagination]").append('<li class="" aria-disabled="true"><a class="imp-sub" href="#">Save & Exit</a></li>');发布于 2020-07-01 17:34:32
您必须使用以下代码添加一个clear按钮:
$form.find("[aria-label=Pagination]").append('<li class="" aria-disabled="true"><a class="imp-sub" href="#">Reset</a></li>');在当前类的帮助下,我们将重置所选的选项卡:
$('.current').find('input:text').val('');最终版本:
form.find("[aria-label=Pagination]").append (' Clear' );
$(".btnClr").click(function() { validator.resetForm(); console.log(validator); $('.current').find('input:text').val(''); });https://stackoverflow.com/questions/24460458
复制相似问题