Created
December 3, 2013 11:17
-
-
Save jimboroberts/7767582 to your computer and use it in GitHub Desktop.
Bootstrap & jquery validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="errormsg"><ul></ul></div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label">Title <div class="required">*</div></label> | |
<div class="col-sm-10"><input type="text" class="input-xlarge form-control" name="title_auc" id="title_auc" value="<?php echo $row_auction['title_auc']; ?>"/></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#form1").validate({ | |
rules:{ | |
email_inv:{ | |
required:true, | |
email: true | |
} | |
}, | |
messages:{ | |
email_usr:{ | |
email:"Enter valid email address" | |
} | |
}, | |
errorClass: "help-block", | |
errorElement: "span", | |
/* | |
wrapper: "li", | |
errorContainer: "#errormsg", | |
errorLabelContainer: "#errormsg ul", | |
invalidHandler:function() { | |
$(errormsg).addClass('alert alert-danger'); | |
}, | |
*/ //Use if all validation in container not on element "<div id="errormsg"><ul></ul></div>" | |
highlight:function(element, errorClass, validClass) { | |
//$(errormsg).addClass('alert alert-danger'); //Container not element | |
$(element).parents('.form-group').addClass('has-error'); | |
}, | |
unhighlight: function(element, errorClass, validClass) { | |
$(element).parents('.controls').removeClass('has-error'); | |
$(element).parents('.form-group').addClass('has-success'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment