Saturday, March 27, 2010

Javascript focus() , Text field focus. focus().----> Alternative code to focus()

Javascript focus()
Text field focus. focus().
Alternative code to focus()
Under IE, when an error occurs the cursor returns to the field with the error. Under Firefox, the cursor stays in the next (tabbed to) field. Is there a way to code this validation so that it would work for both??

Program:
<html>
<head>
<script language='javascript'>
function check()
{
    alert('hii');
    //document.joe.burns.focus(); This is valid for only internet explorer. And will not work on Firefox
    document.getElementById("
burns").focus();
    setTimeout("document.getElementById('burns').focus();",0);
}
function check2()
{
var letters2 = document.joe.tammy.value.length +1;
if (letters2 <= 4)
{document.joe.tammy.focus()}
else
{document.joe.chloe.focus()}
}

</script>
<body>
<FORM NAME="joe">
One:<INPUT TYPE="text" name="burns" id="burns" size="10" onchange="check()"><BR>
Two:<INPUT TYPE="text" name="tammy" size="10" onchange="check2()"><BR>
<INPUT TYPE="submit" VALUE="Click to Send" NAME="go">
</FORM>
</body>
</html>


--
******************************************************
http://www.venkatmails.blogspot.com/

We are richer when we give and poorer when we keep!
-------------------------------------------------
By the next 10 months, our earth will become 3 degrees hotter than its now .
Our himalayan glaciers are melting at a rapid rate. So all of you lend your
hands to fight global warming -Plant more trees .Don't waste water
--Don't use or burn plastic. - Control paper use.
-------------------------------------------------
"The fastest way to succeed is to double your failure rate." --Thomas J. Watson, Founder of IBM
-------------------------------------------------
A lion wakes up everyday and starts running after a deer to survive.
A deer wakes up everyday and starts running from a lion to survive.
So the point is that it does not matter whether you are a lion or a deer.
You just have to keep running.

http://www.venkatmails.blogspot.com/
******************************************************

No comments:

Post a Comment