Skip to main content

Bug Tracker

Side navigation

#11791 closed bug (invalid)

Opened May 21, 2012 06:40AM UTC

Closed May 21, 2012 03:58PM UTC

Strange focus event behaviour in Firefox

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Hi, this is the complete code block example

Expected behaviour is: Once a user clicks the textbox and it has focus, a helper text is displayed right to it. The main requirement is that the focus behaviour is dynamically bound, because form fields can be dynamically added or removed.

There are three main switches which you can 'radio'-comment/uncomment A1, A2, A3 and three sub-switches B1, B2, B3 for A3. The bug appears only in Firefox (v.12 in my case, could not reproduce in other browsers - works as expected) and only in combination A3/B3 ($(document).on ).

The bug is that the event fires and the helper text is visible upon page entering, not after textbox gets focus.

<html lang="en-US">
	<meta charset="UTF-8">
	<script type="text/javascript" src=""></script>
	<form id="form">
		<input type="text" placeholder="Enter username" id="username" data-val-init="Helper text" autocomplete="off">
		<label id="txtlbl" for="username" class="feedback"></label>
<script type="text/javascript">
	/* A1 */
	/*$('#username').live('focus', function(){
		var text = $('#username').attr('data-val-init');
	/* A2 */
	/*$(document).on('focus', '#username', function(){
	(function ($) {
		$.fn.validate = function (options) {
			var defaults = {
				validatedFields: '',
			var settings = $.extend(defaults, options);
			this.validateFields = function () {
				var valid = true;
				return valid;
			return this.each(function () {
				$(settings.validatedFields).each(function () {
					var $field = $('#' + $(this).attr('id'));
					var $label = $;
					/* B1 */
					//$'focus', function () {
					/* B2 */
					//$field.focus(function () {
					/* B3 */
					$(document).on('focus', $field, function () {
						if ($field.val() == '') {
							$label.text($field.hasAttr('data-val-init') ? $field.attr('data-val-init') : '');

	/* A3 */
	$("#form").validate({ validatedFields: '#username' });
	$.fn.hasAttr = function (name) {
		return this.attr(name) !== undefined && this.attr !== false;

Attachments (0)
Change History (2)

Changed May 21, 2012 06:47AM UTC by comment:1

I did not put this on JS fiddle because there it seems to be working fine (when I put the whole JS section into JS box)

Changed May 21, 2012 03:58PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

This isn't really reduced to a bug report form, especially with all the confusing commented-out cases. Try the forum or StackOverflow and if the group collectively comes to the conclusion that jQuery is doing something wrong, open a ticket with a specific description. Also keep in mind that this may be a Firefox bug you should report to them, and not to us.