UNPKG

bootstrapvalidator

Version:

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

25 lines (22 loc) 750 B
(function($) { $.fn.bootstrapValidator.i18n.digits = $.extend($.fn.bootstrapValidator.i18n.digits || {}, { 'default': 'Please enter only digits' }); $.fn.bootstrapValidator.validators.digits = { /** * Return true if the input value contains digits only * * @param {BootstrapValidator} validator Validate plugin instance * @param {jQuery} $field Field element * @param {Object} [options] * @returns {Boolean} */ validate: function(validator, $field, options) { var value = $field.val(); if (value === '') { return true; } return /^\d+$/.test(value); } }; }(window.jQuery));