aquafin
March 8th, 2005, 08:55 PM
If the user doesn't provide the name , an alert box should be displayed and the text box should get focus
And I want to perform the validation before going to the next page(log.asp),i.e before the log.asp page gets displayed.
I have used document.frm.txtbox_name.focus(); ,but that doesn't work
Can anyone help me with this?
<html>
<head>
<script language="JavaScript">
function show()
{
if (document.frm.txtbox.value=="")
{
window.alert("enter name");
document.frm.txtbox.focus();
}
}
</script>
</head>
<body>
<form name="frm" method="post" action="log.asp">
Name:
<input type="text" name="txtbox">
<input type="Submit" value="Enter Name" onClick="show()">
</form>
</body>
</html>
Regards
And I want to perform the validation before going to the next page(log.asp),i.e before the log.asp page gets displayed.
I have used document.frm.txtbox_name.focus(); ,but that doesn't work
Can anyone help me with this?
<html>
<head>
<script language="JavaScript">
function show()
{
if (document.frm.txtbox.value=="")
{
window.alert("enter name");
document.frm.txtbox.focus();
}
}
</script>
</head>
<body>
<form name="frm" method="post" action="log.asp">
Name:
<input type="text" name="txtbox">
<input type="Submit" value="Enter Name" onClick="show()">
</form>
</body>
</html>
Regards