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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post Database entry valid?

    Is there a way or a function that I could use to check a user's entry before submitting it to the database? i mean is there a way that I can scan the user's entry for all characters that would be illegal for database storage?

    And i don't mean like simple form validation where you check to see that the user entered text and not numbers for example.

    I mean like a big text area that you plan to store as a memo field. How can you know that the entry willl be valid?

  • #2
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    you can see if they have entered only valid characters by using InStr and Asc(i) in a loop.. something like this

    Code:
    strTextToBeChecked = "hello $ how are you today jy13?"
    
    blnIllegalChars = False
    For i = Chr(A) to Chr(Z)
    	If InStr(UCase(strTextToBeChecked), Asc(i)) Then blnIllegalChars = True
    Next
    
    If blnIllegalChars = True Then
    	Response.Write "illegal chars entered!"
    Else
    	Response.Write strTextToBeChecked
    End If
    this checks letters only, you could change this to include numbers or whatever, i just cant remember which numbers should be included, you could also check this against lowercase characters or whatever

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    It gives me this error:

    Error Type:
    Microsoft VBScript runtime (0x800A000D)
    Type mismatch: '[string: ""]'
    /thegroupgenesis/tests/testing2.asp, line 8

    Oh and please remember that the database will permit the use of characters that fall outside of the A - Z range as in some characters are allowed in the database.... but others are not.


    What I wanna find out is filtering out those are not
    Last edited by jaywhy13; 01-13-2005 at 04:08 PM.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    yea, i didnt test it and i said you should change it to include the right characters.. its probably an error on Chr(A) should be Chr("A")

    i cant test from college

    my point was its probably smaller to loop through these than loop through the string, using instr instead of looping with mid etc which is what a lot of people do.. im just showing a not too unefficient way of doing it, as it only has a max of 255 itterations, you could probably do a - 9 or something liek that, and then to ^ or whatever like that in a separate loop, just grouping them together as you can, i cant say wht to use 'cos i dont know the numbers and i dont know what characters you want to be illegal

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks for your help thus far.... but this really has nothing to do with what characters I want to be illegal, rather it has Everything to do with the characters that are illegal in MS Access.

    The problem has been plaguing me...... I write some text, copy one or two symbols... and then my page doesn't load and I get a nasty access error instead....

    So I know that there are characters that are illegal... i want users to be able to use all the symbols that are legal.... but prompt them when they are using symbols that aren't legal


  •  

    Posting Permissions

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