Hi,
I have a form with only 1 input field. If I click submit without inputting anything, the alert box pop up with the error message.
The problem is when I click 'ok' on the alert box, it takes me to the next page (as specified on the form action). I want it to stay on the same page so I can input the data as required. Please help.
Thanks in advance.
I have a form with only 1 input field. If I click submit without inputting anything, the alert box pop up with the error message.
The problem is when I click 'ok' on the alert box, it takes me to the next page (as specified on the form action). I want it to stay on the same page so I can input the data as required. Please help.
Thanks in advance.
Code:
<html>
<head>
<title>Payable Invoice Maintenance</title>
<link rel="stylesheet" href="css/style.css" type="text/css" >[COLOR=red]
<script type="text/javascript" defer>
<!--
function check_input()
{
if (document.f1.invnumber.value=="")
{
alert ("Invoice# must be entered.");
document.f1.invnumber.focus();
return false;
}
}
-->
</script>[/color]
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" bgcolor="#edecd7">
<form name="f1" method="post" action="mv_ap_detail.asp?">
<tr>
<td><img src="images/spacer.gif" width="1" height="375" border="0"></td>
<td><img src="images/spacer.gif" width="10" height="1" border="0"></td>
<td valign="top">
<table cellspacing="0" cellpadding="0" border="0"width="100%">
<tr><td colspan="2"><img src="images/spacer.gif" width="40" height="1" border="0"></td></tr>
<tr><td colspan="2"><img src="images/spacer.gif" width="1" height="19" border="0"></td></tr>
<tr>
<td><img src="images/spacer.gif" width="40" height="1" border="0"></td>
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="ver10pxgry2" width="105" align="right"><b>Invoice#</b></td>
<td><img src="images/spacer.gif" width="10" height="1" border="0"></td>
<td><img src="images/spacer.gif" width="5" height="1" border="0"></td>
[COLOR=red] <td><input class="ver10pxblk" type="text" name="invnumber" size="20"></td> [/color]
</tr>
<tr>
<td ><img src="images/spacer.gif" width="3" height="19" border="0"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td><img src="images/spacer.gif" width="430" height="1" border="0"></td>
<td><img src="images/spacer.gif" width="20" height="1" border="0"></td>
[COLOR=red] <td><input type="image" name="submit" value="f1" src="images/btn_submit_tracking.gif" border="0" onclick="check_input()"></td>[/color]
</tr>
</table>
</td>
</tr>
</table>
</td>
<td><img src="images/spacer.gif" width="40" height="1" border="0"></td>
</tr>
</form>
</table>