|
-
focus() & select() not working
Hi
I have some code that validates a field. The code is called using the
onchange event for the input field. The code is;
function CheckDate(ObjectName)
{ if(!isDate(ObjectName))
{ msg = 'Date is not valid.';
alert(msg);
ObjectName.select();
ObjectName.focus();
}
}
The select() and focus() are not working. I suspect the problem is the
order of events. If I enter invalid data and press TAB, the warning
appears, but the cursor moves to the next field. I think the select() and
focus() may be working, but the key press (the TAB) is executed after the
script, so the focus moves to the next field. If I use the onblur event
instead of the onchange event, the code works. I'm guessing this is becuase
the onblur happens after the key press is executed. I can't use the onblur
event for other reasons. Is there anyway to get the onchange event working
with validation code that moves the focus?
Thanks for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks