Labels and click events

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

When you click on a label, the click event of the related form field should fire. Unfortunately Opera and Explorer Mac don't always do this.

Explorer Mac doesn't fire the click event on text fields and textareas, while Opera only fires the click events on radios and checkboxes.

Test page. Workaround is not included.
Reported by ppk.

Explorer Mac, Opera | Reported on 8 February 2005.

Comments

(Add your own)

Posted by Philippe on 8 February 2005

1

Using Opera, I can click on a label, and it will select the appropriate input field, whatever that one is (radio, checkbox, input[type=text], textarea,select).

Posted by ppk on 8 February 2005

2

Sure, but the click event fires only on radios and checkboxes.

Posted by Wout on 8 February 2005

3

Don't get mad at me, I'm just here to learn, but should the click events fire when you just approach the input tags?

Posted by Ben Lawson on 8 February 2005

4

I agree with Wout: click events should not be fired on text fields and textareas, only draw focus to the referenced field. However, clicking a label for a radio or checkbox field should trigger the click event... as well as checking and/or unchecking the associated form field. One oddity I've noticed is that although IE/Mac will trigger the click event for a checkbox, it will NOT check or uncheck the checkbox! What's the sense in that?

Posted by ppk on 8 February 2005

5

No. A click on the label should be treated as a click on the form field, including any event handlers.

Without this it's impossible to use labels in advanced forms where clicking on elements triggers JavaScripts.

Posted by Chris Hester on 10 February 2005

6

Works fine in Opera 7.54u2/WinXP for me. I get an alert when clicking on every one of the form elements, not just the radio buttons and checkboxes.

Posted by ppk on 10 February 2005

7

Please read carefully. Clicking on the form fields is not the issue.

Posted by boo on 17 August 2005

8

Win IE 5: with 3 radio inputs + their respective labels, the 2nd label will not check its input, although the onClick on the label is fired.

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes