posabsolute / jQuery-Validation-Engine

jQuery form validation plugin
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
2.57k stars 1.2k forks source link

Inline Ajax Validation when using square brakets in input id #911

Closed ghost closed 5 years ago

ghost commented 8 years ago

There is an issue with Inline Ajax Validation when the caller input field has square brakets in its id.

Sample HTML (input) <input type="text" class="validate[ajax[checkIban]]" maxlength="40" size="50" name="structure[iban]" value="" id="structure[iban]">

Custom ajax control configuration "checkIban": { "url": "phpajax/iban.php", "alertTextOk": "* ok", "alertText": "* alert", "alertTextLoad": "* load" },

The problem lies in row 1476 in 2.62 version: var errorField = $("#"+ errorFieldId).eq(0);

Library should escape special characters in errorFieldId variable, or else it won't be able to find the element. Should be something like this:

var errorField = $("#"+ errorFieldId.replace( /(:|\.|\[|\]|,)/g, "\\$1" )).eq(0);