O'Reilly logo

Mastering HTML5 Forms by Gaurav Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Error messages

Nowadays, all modern browsers support most of the features of HTML5. The functionality of the features is the same in all browsers but there are some differences; one of which is the default error message that the browser, displays.

Some of the default error messages displayed by various browsers are shown in the following screenshot:

Error messages

However, we can change the default error message of the browser with the help of setCustomvalidity. Let us understand this with an example.

The following code changes the default error message of a browser to a custom message:

<script> function check() { varhtmlObject=document.getElementById("input"); if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required