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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BtnSubmit Problem

Status
Not open for further replies.
Nov 15, 2002
13
CA
I have a search field where I want only Numeric values to be inputed.
Below is the code I added.

Sub btnSubmit_OnClick()
If Not IsNumeric(FrmBarcode.Bcode.value) Then
Alert "Only numeric values are accepted"
FrmBarcode.Bcode.Focus
Exit Sub
End If
End Sub

This all works fine, only problem is that the search still goes on for the value entered in the text box. I want to know a way to stop the page from going to the next page if the user enters a non-numeric value.
Below is my form code for the text box and submit button.


<form name=frmBarCode action=&quot;SearchResults.asp?UID=<%=Server.URLEncode(Request.QueryString(&quot;UID&quot;))%>&quot; method=POST> Bar Code

<INPUT TYPE=&quot;Text&quot; name=&quot;BCode&quot; size = 10>
<INPUT TYPE=submit Value=&quot;Submit&quot; name=&quot;btnSubmit&quot;>


</FORM>









 
Two ways (each works without the other being needed)...

1. put the onSubmit call in your form tag. Write a funciton that checks the form fields and returns true is the form is ok and false if it is not.
<form onSubmit=&quot;return validForm()&quot;>

2. Use an onBlur even on &quot;bCode&quot;
<INPUT TYPE=&quot;Text&quot; name=&quot;BCode&quot; size = 10 onBlur=&quot;btnSubmit_OnClick&quot;> -- Just trying to help... LOL [ponder]
 
Greattt!!!

It worked!!! I was just thinking about the Onblur method when ur reply cam up.

Thanks a lot!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top