1

Is there a way to override the error message provided by browser? I have a simple html:

<input type="email" name="recipient">

If the email format is incorrect, the browser will show a message like :

in Firefox:

Please enter a email address.

in Chrome:

Please include an @ in the email address... 

I wanna customize this browser provided error message, hope someone can help me on this. Thanks in advance!

huan feng
  • 7,307
  • 2
  • 32
  • 56
  • Please see here http://stackoverflow.com/questions/13798313/set-custom-html5-required-field-validation-message – sylwester Jan 06 '15 at 09:23

1 Answers1

4

You can set a custom validity message like this

$('[name="recipient"]').on('invalid', function(e) {
    e.target.setCustomValidity("This is a custom error message");
});

FIDDLE

adeneo
  • 312,895
  • 29
  • 395
  • 388