Hi,
I have an asp that contain a form table. It validate some of the fields when user click 'update' botton. Then submit itself (to add or update to database file). Then redirect to the previous page.
It was working fine until I change the input type="botton" to input type="image". The problem now is when alert box pops up (error in ponumber or invamount) and I click 'ok' on the alert box, the asp page got reload and all the information on the form is gone. Please help.
Here is a function that get called when click save (or update button)
Here is some code in the form. All I changed was the code in red.
I have an asp that contain a form table. It validate some of the fields when user click 'update' botton. Then submit itself (to add or update to database file). Then redirect to the previous page.
It was working fine until I change the input type="botton" to input type="image". The problem now is when alert box pops up (error in ponumber or invamount) and I click 'ok' on the alert box, the asp page got reload and all the information on the form is gone. Please help.
Here is a function that get called when click save (or update button)
Code:
function check_input()
{
if (ltrim(document.f1.ponumber.value==""))
{
alert ("P.O # is Required");
document.f1.ponumber.focus();
return false;
}
if (isNaN(ltrim(document.f1.invamount.value)))
{
alert ("Invalid Invoice Amount Entered. Please Enter an Integer.");
document.f1.invamount.focus();
return false;
}
else if (ltrim(document.f1.invamount.value)== 0 || (document.f1.invamount.value==""))
{
alert ("Invoice Amount must be Entered.");
document.f1.invamount.focus();
return false;
}
document.f1.flag.value = "1"
document.f1.submit();
}
Code:
<table cellspacing="0" cellpadding="0" border="0" bgcolor="#edecd7">
<form action="mv_ap_detail.asp" method="post" name="f1">
<input type="hidden" name="flag" value="<%=strflag%>">
<input type="hidden" name="hdninvnumber" value="<%=strinvnumber%>">
.... some output and input fields ......
<tr>
<td width="125" align="right" class="ver10pxgry2"><B>Inv. Amount</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="invamount" class="ver11pxblk" type="Text" size="10" value="<%=strinvamount%>"></td>
<td class="ver10pxgry2" align="right"><b>Due Date</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="duedate" class="ver11pxblk" type="Text" size="15" value="<%=strduedate%>" onchange="check_date(this)"></td>
</tr>
<tr><td><img src="images/spacer.gif" width="1" height="10" border="0"></td></tr>
<tr>
<td width="125" align="right" class="ver10pxgry2"><B>Department#</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="department" class="ver11pxblk" type="Text" size="6" maxlength="6" value="<%=strdepartment%>"></td>
<td class="ver10pxgry2" align="right"><b>P.O.#</b></td>
<td ><img src="images/spacer.gif" width="5" height="1" border="0"></td>
<td><input name="ponumber" class="ver11pxblk" type="Text" size="20" maxlength="20" value="<%=strponumber%>"></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td><img src="images/spacer.gif" width="1" height="30" 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="save" value="f1" src="images/btn_save_cream.gif" border="0" onclick="check_input()"></td>
<!-- <td><input type="Button" name="update" value="update" class="ver12pxgrn" onclick="check_input()" ></td>-->[/color]
</tr>
<tr><td ><img src="images/spacer.gif" width="1" height="5" border="0"></td></tr>
</table>