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
Printable View
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
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
Here is a quick exmaple :)Quote:
Originally Posted by lchi
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>