Can't find fields with special characters in id
If a field has an id with special jquery selector characters, then inFieldLabels can't find the field from the label's for tag. These ids should be escaped when constructing the jquery selector.
The special jquery characters listed in the jquery API are:
!"#$%&'()*+,./:;<=>?@[]^`{|}~
Adding this line of code immediately before constructing the $field variable seems to work:
for_attr = for_attr.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, "\\$1");
A simpler alternative would be to fetch the element using $(document.getElementById(id)) (which doesn't need escaping), and then checking if it matches the requisites (either textarea or text-ish input).
On a side note, it would be faster than even the current implementation, leave alone adding a regex replacement.
This solution works well - perhaps a similar solution (perhaps with better performance, if that exists) should be pushed to the master.. Cheers @sanchopancho13
@sanchopancho13 Thanks for your suggested fix, but I agree with @streetpc. I'll just switch to getElementById.