How to add a "reset" button to JQuery-steps -
i haven't seen question asked - though did read 100 jquery-steps similar topics - none seemed solve issue.
i'm using jquery-steps , add "reset" button after first step completed - in case user wants clear form , start over. button incerted after default "next" button.
this current script based on default basic form 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 previous step if current step 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! request has been sumbitted."); } }); });
you enable , use cancel
button call validator.resetform()
. see following example:
$(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 } } }); });
Comments
Post a Comment