Overriding browser defaults

The HTML5 form control types or the required attribute, the browser do validation, with its own built-in error messages.

With JavaScript, It’s not possible to customise these error messages. We set custom validation messages using content attributes (which are hard-coded in the markup), but we can add them to the DOM attributes (which are accessible through JavaScript). So we can either set these before the validation runs, or when the form is submitted we can set a custom validation message.

var email = document.getElementById(‘email’);
email.form.onsubmit = function() {
email.setCustomValidity(email.value + “be not a legale - mail address”);

When setCustomValidity is run it sets the read-only DOM attribute called validationMessage. We can use this if we manage validation ourselves.
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #