Reputation: 304
Using ASP.NET MVC I've created a multistep form, for the client side validation I've picked Parsley.js, all works fine except when moving to a previous step in the form the validation is getting triggered (which makes perfect sense since the form is being submitted).
My Parsley related code currently looks like this
element.parsley({
trigger: 'change',
successClass: "success",
errorClass: "error",
classHandler: function (el) {
return el.$element.closest('.c-input');
},
errorsWrapper: '<p class="o-col-12"></p>',
errorTemplate: '<span></span>',
});
Where the element is my form.
Is there an easy way of saying to parsley that the validation shouldn't occur when hitting a specific button (can't see anything in the documentation...) or do I need to rework how the validation currently is attached. So only triggering the validation when hitting the next/submit button.
And yes I've looked at the multistep form example they have on the parsley site but that already has all the steps loaded and just toggles those, I need to submit between steps since server side code needs to happen.
Upvotes: 0
Views: 493
Reputation: 79562
I think you're looking for the novalidate
attribute:
This Boolean attribute indicates that the form is not to be validated when submitted. If this attribute is not specified (and therefore the form is validated), this default setting can be overridden by a formnovalidate attribute on a or element belonging to the form.
Parsley respects it.
Upvotes: 1