How to apply <novalidate> to Action Modals

Sometimes I prefer to use the backend validations rather than the browser validations. Any idea idea how to insert novalidate to the <form> from Action modals?
5 Replies
LeandroFerreira
LeandroFerreira6mo ago
what browser validations?
Dennis Koch
Dennis Koch6mo ago
The default validation you get when you add required etc attributes to your inputs.
LeandroFerreira
LeandroFerreira6mo ago
yes, but we have more than required I guess instead of ->required() we can use ->rules(['required'])... this is why I'm asking
awcodes
awcodes6mo ago
Only way to do this currently using novalidate on the form would be with JS
vahnmarty
vahnmartyOP6mo ago
yes, I tried the js way:
// Select all forms on the page
const forms = document.querySelectorAll('form');

// Iterate over each form and add the novalidate attribute
forms.forEach(form => {
form.setAttribute('novalidate', true);
});
// Select all forms on the page
const forms = document.querySelectorAll('form');

// Iterate over each form and add the novalidate attribute
forms.forEach(form => {
form.setAttribute('novalidate', true);
});
but everytime i click the action button, the attributes gone.

Did you find this page helpful?