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" />
HTML input type="hidden"
Approach: First we create an HTML document that contains an <input> tag. Use the <input> tag with autocomplete attribute. Set the autocomplete attribute to value “off”.
Error trigger: it's a known feature of Chrome 10, if required is present in input [1]. Solution: use formnovalidate in whatever button that triggers the prompt [2], or simply use novalidate in form tag.
Since 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/
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