Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-15-2002, 07:37 PM   PM User | #1
Hatch
New Coder

 
Join Date: Jun 2002
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Hatch is an unknown quantity at this point
Form Validation

Can someone point me in the right direction or (example) for form validation. I have a text box field in a form that connects to an access database. I want to check for numeric numbers only, and also if the record is not found to display a recond not found page instead of
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
Thanks
Hatch is offline   Reply With Quote
Old 07-15-2002, 08:10 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Run this asp code to check for numaric numbers.

Code:
Dim xC, vC, zC
zC=ControlToValidate
vC = "1234567890"

For xC = 1 To Len(zC)
     If Instr(vC, Mid(zC, xC, 1)) < 1 Then
     'Error!

     Exit For
     End If
Next
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-15-2002, 08:12 PM   PM User | #3
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Then for the database part:

Code:
'Run your query first

If rs.EOF or rs.BOF then Response.Redirect("NotFound.aspx")
Change 'rs' to whatever your recordset control name is.
oracleguy is offline   Reply With Quote
Old 07-15-2002, 08:58 PM   PM User | #4
Hatch
New Coder

 
Join Date: Jun 2002
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Hatch is an unknown quantity at this point
PERCECT!!
Thanks
Hatch is offline   Reply With Quote
Old 07-16-2002, 07:33 PM   PM User | #5
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
Am I a newbie for asking this?
What are "numaric numbers"?
Morgoth is offline   Reply With Quote
Old 07-16-2002, 07:41 PM   PM User | #6
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
I think he ment numaric characters/integers.
oracleguy is offline   Reply With Quote
Old 07-16-2002, 07:44 PM   PM User | #7
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
Ah...

and that is?
Morgoth is offline   Reply With Quote
Old 07-17-2002, 02:22 AM   PM User | #8
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
0-9.

Morgoth, please limit your posts in this forum to questions about ASP or attempting to help someone with their ASP problem.

Understood?
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 07-17-2002 at 02:26 AM..
whammy is offline   Reply With Quote
Old 07-17-2002, 07:36 AM   PM User | #9
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
Ok Whammy, but alot of this is new to me, and i want to suck up all the info I can so my code and applications will be perfect or close to being that way.
Morgoth is offline   Reply With Quote
Old 07-17-2002, 02:18 PM   PM User | #10
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Sorry if I was mistaken, it seemed to me you were being a smart aleck.

Anyway, he apparently wanted to limit the entry to digits - FYI here's another neat way to strip everything but numbers from a string using javascript with asp:

<script language="javascript" runat="server">
function ExtractNumbers(MixedString){
if(MixedString){
MixedString = MixedString.replace(/\D/g,'');
return MixedString;
}
}
</script>

You'd call that function just like a VBScript function. So, in addition to the way Oracleguy showed above, you could also see if something extracted from a database was only numeric like:

<%
If myString <> ExtractNumbers(myString) Then
'It's not numeric!
End If
%>
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:07 PM.


Advertisement
Log in to turn off these ads.