|
| |
|
|
wizard_oz
Posts: 140 Joined: 9/3/2004 From: Ga,USA Status: offline
|
submit problem - 2/11/2008 13:46:30
Hi, I have a problem with checking some fields before click the SUBMIT button. I would like to check the fields and if the feilds are empty I would give a message that say "the feild is empty" and if not, continue to the next page my code is simple and look like:
<form action="InsertDB.asp" method="get" id="form1" name="form1">
<input id="UserName" name="UserName" class="ghi" >
<INPUT type="submit" value="Submit" id=submit2 name=submit2>
</FORM>
any Idea PLEASE....
|
|
|
|
Catherine Sea
Posts: 2 Joined: 1/1/2008 Status: offline
|
RE: submit problem - 2/25/2008 20:22:56
You can use the event handler called onsubmit to check the fields. Below is the code: <script language="javascript">
function checkfields()
{
var txtUserName = document.getElementById("UserName");
if(txtUserName && txtUserName.value == "")
{
alert("the feild is empty");
return false;
}
}
</script>
<form action="InsertDB.asp" method="get" id="form1" name="form1" onsubmit="return checkfields()">
<input id="UserName" name="UserName" class="ghi" >
<INPUT type="submit" value="Submit" id=submit2 name=submit2 >
</FORM> This code works well. I hope this will help you. -- Catherine Sea http://www.dynamsoft.com/
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|