Sha256: 874bc574e7a9327047a1c427cf3255b7647f060e21a6f38ce7e354292e7f2ab9
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
(function($) { $.fn.bootstrapValidator.i18n.regexp = $.extend($.fn.bootstrapValidator.i18n.regexp || {}, { 'default': 'Please enter a value matching the pattern' }); $.fn.bootstrapValidator.validators.regexp = { html5Attributes: { message: 'message', regexp: 'regexp' }, enableByHtml5: function($field) { var pattern = $field.attr('pattern'); if (pattern) { return { regexp: pattern }; } return false; }, /** * Check if the element value matches given regular expression * * @param {BootstrapValidator} validator The validator plugin instance * @param {jQuery} $field Field element * @param {Object} options Consists of the following key: * - regexp: The regular expression you need to check * @returns {Boolean} */ validate: function(validator, $field, options) { var value = $field.val(); if (value === '') { return true; } var regexp = ('string' === typeof options.regexp) ? new RegExp(options.regexp) : options.regexp; return regexp.test(value); } }; }(window.jQuery));
Version data entries
4 entries across 4 versions & 2 rubygems