Browse Source

Adds decimal and number validation to form #2537

pull/2869/head
Jack Lukic 9 years ago
parent
commit
22b874af75
1 changed files with 15 additions and 4 deletions
  1. 19
      src/definitions/behaviors/form.js

19
src/definitions/behaviors/form.js

@ -988,10 +988,12 @@ $.fn.form.settings = {
regExp: {
bracket : /\[(.*)\]/i,
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
decimal : /^\-?\d*(\.\d+)?$/,
email : "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
integer : /^\-?\d+$/,
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
flags : /^\/(.*)\/(.*)?/,
integer : /^\-?\d+$/,
number : /^\-?\d*(\.\d+)?$/,
url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i
},
@ -1018,10 +1020,10 @@ $.fn.form.settings = {
},
error: {
oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.',
identifier : 'You must specify a string identifier for each field',
method : 'The method you called is not defined.',
noRule : 'There is no rule matching the one you specified',
method : 'The method you called is not defined.'
oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.'
},
templates: {
@ -1124,6 +1126,15 @@ $.fn.form.settings = {
);
},
// is valid number (with decimal)
decimal: function(value) {
return $.fn.form.settings.regExp.decimal.test(value);
},
// is valid number
number: function(value) {
return $.fn.form.settings.regExp.number.test(value);
},
// is value (case insensitive)
is: function(value, text) {

Loading…
Cancel
Save