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/
jQuery("#product_addtocart_form").validate({
rules: {
"options[483998]": {
required: true,
range: [100, 2540]
}
}
});
Just put it in quotes: "options[483998]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With