Validate Plugin - ID selection not working correctly
I have jquery.validate 1.10.0 and jquery 1.7.2
Part of my form has 2 address fields but I would like only the first to be required -
- <tr>
- <th>First Line of Address</th>
- <td><input name="address" size="26" type="text" value="" id="address-input-0" onkeydown="javascript:is_changed()" /></td>
- </tr>
- <tr>
- <th>Second Line of Address</th>
- <td><input name="address" size="26" type="text" value="" id="address-input-1" onkeydown="javascript:is_changed()" /></td>
- </tr>
I don't have control over any of the input attributes and they both have name="address" so I have to use the ID - (I can't remove the onkeydown="javascript:is_changed()" either).
- $("#account_details").validate();
- $("#address-input-0").rules("add", {required:true});
Only when tabbing through the form I get 'This field is required' in text for
both of the address fields.
However, having tested a bit more, it does let me submit the form if the Second Address field is empty. But not when the first is empty. So basically it works, but users are going to be confused. Anything I can do to fix this?