Using the jquery form plugin. I was trying to test the value of a form element that uses square brackets.
var form = jqForm[0];
if (!form.sendTo\\[\\].value) {
alert('Something');
return false;
}
Despite trying to escape the brackets it is still giving me a an error.
illegal character
[Break On This Error] if (!form.sendTo\[\].value) {
is it not possible to do this?
Thanks
you can use a square brackets and a string in place of dot-notation in javascript. So try this:
Edit after comments:
Using jQuery you can determine how many checked checkboxes there are using code such as:
assuming
formis a jQuery object referencing the form containing the checkboxes. if it’s not, you should be able to wrap it like$(form)in the example above.Live example: http://jsfiddle.net/TMSsq/