I have a page with duplicate ID's for a form element. The catch is I the elements show up separately based on a toggle. So both ID's never show up simultaneously.
However when I do form validation on that element, it always selects the element displayed last in the code (even if its hidden).
Is there a selector to select the visible duplicate ID?
I've tried the following but to no avail:
$('#my_element:visible').val();
$('#my_element').not(':hidden').val();
Also, is there a reason you can't use class names instead of IDs since, IDs are technically for a single element on a page that is never repeated?