esedic
2/23/2015 - 9:40 AM

Set custom message for html5 form validation

Set custom message for html5 form validation

jQuery(document).ready(function($){
  $('#form-id input[type=text]').on('change invalid', function() {
    var textfield = $(this).get(0);

    textfield.setCustomValidity('');

    if (!textfield.validity.valid) {
    textfield.setCustomValidity('Custom Message');  
    }
  });
});