| 12345678910111213141516171819202122232425262728293031323334 |
- (function($) {
- $.fn.bootstrapValidator.validators.stringCase = {
- html5Attributes: {
- message: 'message',
- case: 'case'
- },
- /**
- * Check if a string is a lower or upper case one
- *
- * @param {BootstrapValidator} validator The validator plugin instance
- * @param {jQuery} $field Field element
- * @param {Object} options Consist of key:
- * - message: The invalid message
- * - case: Can be 'lower' (default) or 'upper'
- * @returns {Boolean}
- */
- validate: function(validator, $field, options) {
- var value = $field.val();
- if (value == '') {
- return true;
- }
- var stringCase = (options.case || 'lower').toLowerCase();
- switch (stringCase) {
- case 'upper':
- return value === value.toUpperCase();
- case 'lower':
- default:
- return value === value.toLowerCase();
- }
- }
- };
- }(window.jQuery));
|