31 Mar 2007 at 13:57 #1 ringo747 ringo747 Soldato Joined 1 Feb 2006 Posts 8,188 hi, trying to do some javascript validation here and I want to set the focus back to a certain field if it is empty. This is the code I am using but this doesn't seem to work! Any ideas? Code: document.getElementById("title").focus();
hi, trying to do some javascript validation here and I want to set the focus back to a certain field if it is empty. This is the code I am using but this doesn't seem to work! Any ideas? Code: document.getElementById("title").focus();
31 Mar 2007 at 16:25 #2 psyr33n psyr33n Associate Joined 5 Mar 2007 Posts 649 Location London No reason why it shouldn't work. Post all of the code (how you are calling said method etc.) Just for reference, the following works: Code: function focusId(id) { document.getElementById(id).focus(); } <p onclick="focusId('title');">HILOL</p> <input type="text" id="title">
No reason why it shouldn't work. Post all of the code (how you are calling said method etc.) Just for reference, the following works: Code: function focusId(id) { document.getElementById(id).focus(); } <p onclick="focusId('title');">HILOL</p> <input type="text" id="title">