Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am calling a sub that checks if t

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
0
0
CA
I am calling a sub that checks if the value in the text box is numeric, on the onclick event of the submit button. If the value is not numeric, is it possible to cancel the action on the form so it doesn't go to the next page?

Is it also possible to load a page without having to click on a button or link?

Here is the code:


<form name = SaveSales action = &quot;SaveSales.asp&quot; action = &quot;GET&quot;>



<tr>
<td align = right>
<b>Please enter the amount of sales for the new store:
    </b></td>
<td align = left>
<input type = &quot;text&quot; name = &quot;sales&quot; size=20>
</td>
</tr>
</table>

<center>
<table border = 0 width = 100%>
<tr align = center>
<td>
<input type = &quot;Submit&quot; value = &quot;Save Sales Amount&quot;
onclick = CheckNumber>
</form>
</td>
</tr>
</table>
</center>
<br><br>
</form>
<center><a href=&quot;Generate.asp&quot; title = &quot;Back to
Splits&quot;>Back to Splits</a></center>

 
I would first move the validation to the onsubmit function of the form. Make sure you include the &quot;ID&quot; property on the objects and set them the same as the &quot;name&quot; property.


<SCRIPT LANGUAGE=vbscript>
function SaveSales_onsubmit()
IF (NOT isnumeric(SaveSales.sales.value)) Then
SaveSales_onsubmit = False
end if
end function
</SCRIPT>


Hope This Helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top