Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  26] [ 4]  / answers: 1 / hits: 16188  / 9 Years ago, fri, september 4, 2015, 12:00:00

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 />



More From » jquery

 Answers
23

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/


[#65185] Wednesday, September 2, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
austynp

Total Points: 505
Total Questions: 118
Total Answers: 106

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
austynp questions
;