Skip to content

Instantly share code, notes, and snippets.

@WenInCode
Created August 29, 2014 21:35
Show Gist options
  • Save WenInCode/32447b224b654fd05abf to your computer and use it in GitHub Desktop.
Save WenInCode/32447b224b654fd05abf to your computer and use it in GitHub Desktop.
an example bootstrap validator callback
// example callback
$('#unitRateItemMapEditForm').bootstrapValidator({
message: 'This is not valid',
feedbackIcons: {
valid:'glyphicon glyphicon-ok',
invalid:'glyphicon glyphicon-remove',
validating:'glyphicon glyphicon-refresh'
},
fields: {
selectId: {
validators: {
callback: {
message: "You must select an option!",
callback: function(value, validator, $field) {
// your custom condition goes here
if (value.length == 0) {
// valid -> false to fail
return: {
valid: false,
message: "need to pick an option dude"
}
}
// you can use more than one condition
// if (foo) {
return true;
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment