Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Form Validation

  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.

  • #4
    New Coder
    Join Date
    Jun 2002
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PERCECT!!
    Thanks

  • #5
    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
    Am I a newbie for asking this?
    What are "numaric numbers"?

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    I think he ment numaric characters/integers.

  • #7
    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
    Ah...

    and that is?

  • #8
    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
    0-9.

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

    Understood?
    Last edited by whammy; 07-17-2002 at 03:26 AM.
    Former ASP Forum Moderator - I'm back!

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

  • #9
    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
    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.

  • #10
    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
    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. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •