Required Field Validator

Discussion in 'ASP .Net' started by Sparky Arbuckle, Feb 20, 2005.

  1. <asp:RequiredFieldValidator
    id="rfvMenuSearch"
    ControlToValidate="tbSearch"
    Display="static"
    ErrorMessage="Enter Search String"
    runat="SERVER" />

    How can I add an Expression Validator to this to cancel out all
    searches for "` ! # ^ ( ) < > /", etc. . . Any insight on if a
    validator is more efficient than a CleanData Function?

    The only other way that I'm thinking it could be done is with Classic
    ASP:

    IF tbSearch.text = "^" OR . . . Thanks for any possible help.
     
    Sparky Arbuckle, Feb 20, 2005
    #1
    1. Advertising

  2. Sparky Arbuckle

    Wilco Bauwer Guest

    You could try to use a RegularExpressionValidator instead:

    <asp:Regu..... ValidationExpression="^[^!#^()<>/]+$" />

    This should match 1 or more characters which are none of the chars you
    described.

    You could also use a CustomValidator, handle its ServerValidate event
    and check if the index of any (String.IndexOfAny) of the chars you
    described is > -1. If that's the case, the expression is invalid, so
    you can set the arguments object's IsValid property to false.

    HTH.
     
    Wilco Bauwer, Feb 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jinsong Liu

    Required Field Validator Client side popup

    Jinsong Liu, Aug 14, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    5,553
    Guenther Liebowitz
    Aug 14, 2003
  2. Do
    Replies:
    3
    Views:
    4,442
    Mike Moore [MSFT]
    Oct 23, 2003
  3. Jim Heavey

    Required Field Validator

    Jim Heavey, Nov 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    337
    Jim Heavey
    Nov 14, 2003
  4. Mr. x
    Replies:
    0
    Views:
    340
    Mr. x
    Nov 30, 2003
  5. jr
    Replies:
    3
    Views:
    471
Loading...

Share This Page