Browse Source

Fixes #283 issue with regexp not escaping on validation

pull/306/head
jlukic 11 years ago
parent
commit
d605078e71
1 changed files with 3 additions and 2 deletions
  1. 5
      src/modules/behavior/form.js

5
src/modules/behavior/form.js

@ -360,7 +360,7 @@ $.fn.form = function(fields, parameters) {
var var
$field = module.get.field(field.identifier), $field = module.get.field(field.identifier),
type = validation.type, type = validation.type,
value = $field.val(),
value = $field.val() + '',
bracketRegExp = /\[(.*?)\]/i, bracketRegExp = /\[(.*?)\]/i,
bracket = bracketRegExp.exec(type), bracket = bracketRegExp.exec(type),
@ -370,7 +370,7 @@ $.fn.form = function(fields, parameters) {
; ;
// if bracket notation is used, pass in extra parameters // if bracket notation is used, pass in extra parameters
if(bracket !== undefined && bracket !== null) { if(bracket !== undefined && bracket !== null) {
ancillary = bracket[1];
ancillary = '' + bracket[1];
functionType = type.replace(bracket[0], ''); functionType = type.replace(bracket[0], '');
isValid = $.proxy(settings.rules[functionType], $module)(value, ancillary); isValid = $.proxy(settings.rules[functionType], $module)(value, ancillary);
} }
@ -652,6 +652,7 @@ $.fn.form.settings = {
return (value != notValue); return (value != notValue);
}, },
contains: function(value, text) { contains: function(value, text) {
text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
return (value.search(text) !== -1); return (value.search(text) !== -1);
}, },
is: function(value, text) { is: function(value, text) {

Loading…
Cancel
Save