|
-
Jan 25th, 2005, 12:17 AM
#1
Thread Starter
Lively Member
Checking a textfield [Resolved]
Hi guys,
I was wondering how you check if a textfield is empty or not before you submit. Maybe a pop up will appear and tell the user that he/she needs to enter a value if there is no value in it.
Irwin
Last edited by lchi; Jan 25th, 2005 at 03:39 AM.
-
Jan 25th, 2005, 12:50 AM
#2
Re: Checking a textfield
Use client side Javascript to check if the textbox is empty or not.
There are (literally) thousands of examples:
http://www.google.com/search?hl=en&l...on&btnG=Search
-
Jan 25th, 2005, 06:41 AM
#3
Re: Checking a textfield [Resolved]
 Originally Posted by lchi
Hi guys,
I was wondering how you check if a textfield is empty or not before you submit. Maybe a pop up will appear and tell the user that he/she needs to enter a value if there is no value in it.
Irwin
Here is a quick exmaple 
HTML Code:
<html>
<head>
<script>
function validate()
{
if (document.form1.txtName.value=="")
{
alert("Please enter your name");
document.form1.txtName.focus();
return false;
}
if (document.form1.txtEmail.value=="")
{
alert("Please enter your email");
document.form1.txtEmail.focus();
return false;
}
}
</script>
</head>
<body>
<form name=form1 onsubmit="return validate()">
Name : <input type=text name=txtName><br>
Email: <input type=text name=txtEmail>
<input type=submit>
</form>
</body>
</html>
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
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
|