Gregory Burns
Gregory Burns

Reputation: 840

Magento 2 form validation resetForm not working

I want to reset form validation after a failed form submit.

I'm using Magneto 2 and init the form validation with data-mage-init='{"validation":{}}'

<form ... data-mage-init='{"validation":{}}'>

I tried to reset the errors like

var validator = jQuery( "#edit-product" ).validate();
validator.resetForm();

But it does not reset. I have a feeling Magento's data-mage-init is doing things differently the standard Jquery Validation and I have to go about resetting the form differently but so far I can's find a way that works.

Upvotes: 0

Views: 1836

Answers (1)

user2487366
user2487366

Reputation: 11

I have tested the code below and it worked for me in Magento 2,

$('#edit-product').validation('clearError');

Upvotes: 1

Related Questions