hide pop-up of required
of input using javascript
jsfiddle
try to submit with empty input and see the pop-up, so i don't need to display that pop-up and i want the required to validate.
any help i don't need to display any warning.
<form>
<input type="text" name="name" required="required" value="" />
<input type="submit" name="submit" value="Submit" />
hide pop-up of required
of input using javascript
jsfiddle
try to submit with empty input and see the pop-up, so i don't need to display that pop-up and i want the required to validate.
any help i don't need to display any warning.
<form>
<input type="text" name="name" required="required" value="" />
<input type="submit" name="submit" value="Submit" />
Share
Improve this question
asked Sep 4, 2015 at 15:17
kadibrakadibra
991 gold badge1 silver badge9 bronze badges
4
- So to understand this correctly, you want to validate the form, but don't want the notification? – Johan Commented Sep 4, 2015 at 15:41
- yes i need the validation but not display notification. – kadibra Commented Sep 4, 2015 at 15:45
- See my comment on Rafa's answer. – Johan Commented Sep 4, 2015 at 15:48
- yes @Johan i need validation to work but not displaying notification. – kadibra Commented Sep 4, 2015 at 15:50
2 Answers
Reset to default 11Since this is a HTML5 Event you can prevent the event from triggering the popup and still provide validation (https://developer.mozilla.org/en-US/docs/Web/Events/invalid). A simple event listener will do the job.
To handle focus include an id to that field like so ...
HTML
<input type="text" id="name" name="name" required="required" value="" />
And handle that focus within the return function ...
JS
document.addEventListener('invalid', (function () {
return function (e) {
e.preventDefault();
document.getElementById("name").focus();
};
})(), true);
EDIT Check it out http://jsfiddle.net/rz6np/9/
autocomplete="off"
or
autocomplete="nope"
If autocomplete still works on an <input>
despite having autocomplete="off", but you can change off
to a random string, like nope.
It appears that Chrome now ignores autocomplete="off"
unless it is on the <form>
-tag.