I have a form containing address fields as such
http://jsfiddle.net/DP3aw/2/
For some reason I have to put the address in multiple text inputs as it is now.
When you click on the 2nd or 3rd input, the focus will jump to the first text field, why is that happening? is there anyway I can prevent that? or do I have to use js/jQuery to stop it from happening?
Thanks!
It’s because you have the all of your
INPUTelements inside theLABELtag. Clicking on a label focuses the associated input. Since all of your inputs are inside the label, they all trigger it, causing the focus to jump to the first input (the one that is associated).Fixed version: http://jsfiddle.net/DP3aw/3/
Broken
Fixed
Possible Improvement
Here’s a more semantically correct version that uses a
FIELDSETfor the general grouping and labels for each individual input. It also demonstrates how clicking on a label will focus its associated input element.http://jsfiddle.net/njY3U/1/