<formid="regexpEmailForm"class="form-horizontal"><divclass="form-group"><labelclass="col-xs-3 control-label">Email address</label><divclass="col-xs-7"><inputtype="text"class="form-control"name="email"/></div></div></form><script>$(document).ready(function(){$('#regexpEmailForm').formValidation({framework:'bootstrap',icon:{valid:'glyphicon glyphicon-ok',invalid:'glyphicon glyphicon-remove',validating:'glyphicon glyphicon-refresh'},fields:{email:{validators:{emailAddress:{message:'The value is not a valid email address'},regexp:{regexp:'^[^@\\s]+@([^@\\s]+\\.)+[^@\\s]+$',message:'The value is not a valid email address'}}}}}).on('err.validator.fv',function(e,data){// data.bv --> The FormValidation.Base instance// data.field --> The field name// data.element --> The field element// data.validator --> The current validator nameif(data.field==='email'){// The email field is not validdata.element.data('fv.messages')// Hide all the messages.find('.help-block[data-fv-for="'+data.field+'"]').hide()// Show only message associated with current validator.filter('[data-fv-validator="'+data.validator+'"]').show();}});});</script>
No comments:
Post a Comment