Skip to content

Commit

Permalink
#4163 #4164 Fixes associative array name values not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Feb 21, 2017
1 parent fb8bccd commit 6e88af1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ $.fn.form = function(parameters) {
metadata,
selector,
className,
regExp,
error,

namespace,
Expand Down Expand Up @@ -262,6 +263,12 @@ $.fn.form = function(parameters) {
}
});
return allValid;
},
validHTMLID(value) {
if(typeof value !== 'string') {
return false;
}
return value.search(regExp.htmlID) !== -1;
}
},

Expand Down Expand Up @@ -465,6 +472,7 @@ $.fn.form = function(parameters) {
metadata = settings.metadata;
selector = settings.selector;
className = settings.className;
regExp = settings.regExp;
error = settings.error;
moduleNamespace = 'module-' + namespace;
eventNamespace = '.' + namespace;
Expand All @@ -477,7 +485,7 @@ $.fn.form = function(parameters) {
},
field: function(identifier) {
module.verbose('Finding field with identifier', identifier);
if( $field.filter('#' + identifier).length > 0 ) {
if(module.is.validHTMLID(identifier) && $field.filter('#' + identifier).length > 0 ) {
return $field.filter('#' + identifier);
}
else if( $field.filter('[name="' + identifier +'"]').length > 0 ) {
Expand Down Expand Up @@ -595,7 +603,7 @@ $.fn.form = function(parameters) {
if(typeof identifier !== 'string') {
module.error(error.identifier, identifier);
}
if( $field.filter('#' + identifier).length > 0 ) {
if(module.is.validHTMLID(identifier) && $field.filter('#' + identifier).length > 0 ) {
return true;
}
else if( $field.filter('[name="' + identifier +'"]').length > 0 ) {
Expand Down Expand Up @@ -1090,6 +1098,7 @@ $.fn.form.settings = {
},

regExp: {
htmlID : /^[a-zA-Z][\w:.-]*$/g,
bracket : /\[(.*)\]/i,
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])?)*$/i,
Expand Down

0 comments on commit 6e88af1

Please sign in to comment.