Created
August 29, 2014 21:35
-
-
Save WenInCode/32447b224b654fd05abf to your computer and use it in GitHub Desktop.
an example bootstrap validator callback
This file contains 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
// 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