We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to clear error messages using formvalidator?

I've got some dynamic validation going on.

using addrules and removerules depending on some other control selected values.

when the form gets validated - error messages appear. so far so good.

now if i, for example remove a required rule from a field, the error message stays visible.

how can i remove the message?

.reset() is not an option because that would empty all the form fields the user already filled.

using 20.1.58


greetings



1 Reply

SP Sureshkumar P Syncfusion Team March 24, 2023 10:30 AM UTC

Hi Michael,

We need to remove the error message manually to achieve your requirement.

Find the code example here:

document.getElementById('resetField').addEventListener('click'function (e) {

  formObj.removeRules('cnic');

  formObj.element

    .querySelector('#cnic')

    .parentElement.querySelectorAll('.e-error')[1]

    .remove();

});

 


Find the sample here: https://stackblitz.com/edit/h5g3ma-lf5hzm?file=index.js

Regards,

Sureshkumar P


Loader.
Up arrow icon