callback.js 1003 B

12345678910111213141516171819202122232425
  1. (function($) {
  2. $.fn.bootstrapValidator.validators.callback = {
  3. /**
  4. * Return result from the callback method
  5. *
  6. * @param {BootstrapValidator} validator The validator plugin instance
  7. * @param {jQuery} $field Field element
  8. * @param {Object} options Can consist of the following keys:
  9. * - callback: The callback method that passes 2 parameters:
  10. * callback: function(fieldValue, validator) {
  11. * // fieldValue is the value of field
  12. * // validator is instance of BootstrapValidator
  13. * }
  14. * - message: The invalid message
  15. * @returns {boolean}
  16. */
  17. validate: function(validator, $field, options) {
  18. var value = $field.val();
  19. if (options.callback && 'function' == typeof options.callback) {
  20. return options.callback.call(this, value, this);
  21. }
  22. return true;
  23. }
  24. };
  25. }(window.jQuery));