UNPKG

bootstrapvalidator

Version:

The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3

29 lines (26 loc) 806 B
(function($) { $.fn.bootstrapValidator.i18n.siren = $.extend($.fn.bootstrapValidator.i18n.siren || {}, { 'default': 'Please enter a valid SIREN number' }); $.fn.bootstrapValidator.validators.siren = { /** * Check if a string is a siren number * * @param {BootstrapValidator} validator The validator plugin instance * @param {jQuery} $field Field element * @param {Object} options Consist of key: * - message: The invalid message * @returns {Boolean} */ validate: function(validator, $field, options) { var value = $field.val(); if (value === '') { return true; } if (!/^\d{9}$/.test(value)) { return false; } return $.fn.bootstrapValidator.helpers.luhn(value); } }; }(window.jQuery));