Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide required pop-up of input in html

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

like image 744
kadibra Avatar asked Sep 04 '15 15:09

kadibra


People also ask

How do you make a hidden field required in HTML?

HTML input type="hidden"

How do I stop show suggestions on my input box?

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”.

How do I get rid of please fill this field in HTML?

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.


1 Answers

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/

like image 150
Rafa Avatar answered Oct 28 '22 03:10

Rafa