|
-
March 8th, 2005, 09:55 PM
#1
validation
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
Manjula
------------
"To err is Human, and to blame it on a computer is even more so.."
-
March 8th, 2005, 10:08 PM
#2
Re: validation
Your form tag should be:
HTML Code:
<form ... onsubmit="return show()">
Your show() function should be:
Code:
function show() {
if(document.frm.txtbox.value=="") {
alert("enter name");
document.frm.txtbox.focus();
return false;
}
return true;
}
Dr. Script
*9-11-01* Never Forget; Never Forgive; Never Relent!
"If we ever forget that we're one nation under God, then we will be a nation gone under." - Ronald Reagan
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
|
Click Here to Expand Forum to Full Width
|