I have the following validation code for a text field but the ‘field’ below needs to be replaced with the name of the text field, which is created dynamically.
My problem is it has a square bracket in the name – options[483998]
How would I go about adding this to the code below as obviously if I do a direct replace of field with options[483998] it creates invalid coding.
jQuery("#product_addtocart_form").validate({
rules: {
field: {
required: true,
range: [100, 2540]
}
}
});
Demo – http://jsfiddle.net/sY82j/