For a group of logins, you can use an improved version based on @mikemaccana's answer
$.fn.isValid = function(){ var validate = true; this.each(function(){ if(this.checkValidity()==false){ validate = false; } }); };
now you can use this to check if the form is valid:
if(!$(".form-control").isValid){ return; }
You can use the same method to get all error messages:
$.fn.getVelidationMessage = function(){ var message = ""; var name = ""; this.each(function(){ if(this.checkValidity()==false){ name = ($( "label[for=" + this.id + "] ").html() || this.placeholder || this.name || this.id); message = message + name +":"+ (this.validationMessage || 'Invalid value.')+"\n<br>"; } }) return message; }
Matias Medina Feb 29 '16 at 1:45 2016-02-29 01:45
source share