Issue
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.
Solution
In html5
you have two options for input elements:
- Put them inside a
<form>
container. - Add the
form
attribute to the input, the value should be theid
of the form that the input is related to.
Using option #2 you can just add an empty form with the novalidate
somewhere in your DOM and attach the input to that form:
<form novalidate>
<p>Input in form with novalidate. This one is fine.</p>
<input type="email" required>
</form>
<p>Input without form. How to disable validation tooltips? (hover over input to see validation tooltip)</p>
<input type="email" required form="novalidatedform">
<form id="novalidatedform" novalidate />
More information regarding the input
element in MDN website.
Answered By - Dekel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.