If I have an input
within a <form>
element, I can simply add the novalidate
attribute to the form to disable the HTML5 validation tooltips. However, my input is not a in a form element (I am using angularJS and I use ng-form
directive).
I can listen to invalid event and prevent submit validation but I cannot prevent validation tooltips.
Here is a simple JsFiddle to shows the issue.
To ignore HTML validation, you can remove the attribute on button click using JavaScript. Uer removeAttribute() to remove an attribute from each of the matched elements.
Description. You can disable the form validation either by applying the novalidate attribute to the form element, or the formnovalidate attribute to the types of the button and input elements that can submit forms.
If You want to disable the validation for all elements of the form add the novalidate attribute in the form tag which will disable the validation for entire form.
novalidate if a form-level attribute used to turn off validation for a form, despite the attributes of the inputs it contains (i.e. will override inputs with the required attribute, or that would otherwise fail validation).
Although the Accepted answer does the job, one another way how this could be done is by simply adding a 'title' attribute to the input element, and the validation message will be overwritten with the content in title attribute.
You can add some meaningful text in the title attribute,
<input type="email" title="Your Email">
P.S In HTML5, the title attribute can be used on any HTML element unlike in HTML 4.01.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With