Ozzie.eu

Love to code, although it bugs me.

Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

jqBootstrap ignores required field custom error message

jqBootstrap is a JQuery validation framework for bootstrap forms. While using it to validate required fields, on the form submission I got a tooltip with a “required field” message but not the custom I had put on the markup.

In short, “required” is part of the HTML5 standard and it does what it’s supposed to, validates the input on a given field.

Said that and given that the “sniffHtmlsetting didn’t do the trick, I got things done with two control events that customize the HTML5 behaviour:

<input id=“myHtmlControl” name=“myHtmlControl” type=“text” required oninvalid=“this.setCustomValidity(‘You really should write on this field.’)” onchange=“this.setCustomValidity(”)“>

Hope this saves someone time :)