0

hi all,
i am having a login page which includes username, password,submit,clear. ater cuming to this page i am geting focus on textbox but wen i press clear button it is not focusing again on the username text box. so please help me.
Thank u.

3
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

Sample:

<html>
<head>
<title>Add site</title>

</head>
<body onload="setFocus()">

<form action="add_site.php" method="post" name="add_site">
<input type=text name=add_url size=50 value="http://">
<input type=submit value=" add "> 
<input type="reset" value=" reset " name="Reset">
</form>

<script language="javascript">

function setFocus()
{
var field = document.add_site.add_url;
field.focus();
field.value = field.value;
field.focus();
}

</script>

</body>
</html>
0

Sample:

<html>
<head>
<title>Add site</title>

</head>
<body onload="setFocus()">

<form action="add_site.php" method="post" name="add_site">
<input type=text name=add_url size=50 value="http://">
<input type=submit value=" add "> 
<input type="reset" value=" reset " name="Reset">
</form>

<script language="javascript">

function setFocus()
{
var field = document.add_site.add_url;
field.focus();
field.value = field.value;
field.focus();
}

</script>

</body>
</html>

i had tried it. but i am not getting it wen i press clear button.

0

You may call that setFocus() function, when the reset button was pressed:

<input type="reset" value="reset" name="Reset" onclick="setFocus();">

P.S. I don't think a reset button is necessery on a login page.

0

Yes that Right, bcoz when you click reset the page will not refresh, but my code call the setFocus on page load.

Just also call the fn onclick="setFocus();" from reset button input type.

It will work! It works!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.