Skip to content

Commit f1b14a7

Browse files
author
Cedric Dugas
committed
escape special charaters posabsolute#457 ,thanks to @tedliang
1 parent aa93702 commit f1b14a7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

js/jquery.validationEngine.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
errorFound |= methods._validateField(field, options);
329329
if (errorFound && first_err==null)
330330
if (field.is(":hidden") && options.prettySelect)
331-
first_err = field = form.find("#" + options.usePrefix + field.attr('id') + options.useSuffix);
331+
first_err = field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
332332
else
333333
first_err=field;
334334
if (options.doNotShowAllErrosOnSubmit)
@@ -689,7 +689,7 @@
689689
}
690690

691691
if(field.is(":hidden") && options.prettySelect) {
692-
field = form.find("#" + options.usePrefix + field.attr('id') + options.useSuffix);
692+
field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
693693
}
694694

695695
if (options.isError){
@@ -1794,7 +1794,14 @@
17941794
if(className)
17951795
return className.replace(/:/g, "_").replace(/\./g, "_");
17961796
},
1797-
1797+
/**
1798+
* Escape special character for jQuery selector
1799+
* http://totaldev.com/content/escaping-characters-get-valid-jquery-id
1800+
* @param {String} selector
1801+
*/
1802+
_jqSelector: function(str){
1803+
return str.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
1804+
},
17981805
/**
17991806
* Conditionally required field
18001807
*

0 commit comments

Comments
 (0)