Displaying characters that cause a validator to fail

Discussion in 'ASP .Net' started by Stephan Bour, Jan 22, 2004.

  1. Stephan Bour

    Stephan Bour Guest

    Hi,
    I have a regular expression validator that checks a text box string:

    <asp:RegularExpressionValidator id="SeqFormat" runat="server"
    Display="Static" ErrorMessage="Your sequence contains illegal characters"
    ControlToValidate="Sequence"
    ValidationExpression="^[AGTCagtc5678\n\s]{1,}$">

    I'd like to provide the user with a listing of the illegal characters that
    triggered a failure of the validator. Do you know how to capture the illegal
    characters and display them in a label?
    Thanks,
    Stephan.
     
    Stephan Bour, Jan 22, 2004
    #1
    1. Advertising

  2. Stephan Bour

    Peter Blum Guest

    Hi Stephan,

    This may be a much bigger task than its worth. I have a feeling that
    creating an error message telling users what they can type will be far
    easier than writing this validator. (FYI: I am the author of "Professional
    Validation And More", a replacement to Microsoft's validators that is
    designed to overcome its many limitations. In this case, even I haven't
    tackled this thorny issue.)

    This is possible if you basically wrote your own validator using their
    CustomValidator or subclassing from BaseValidator. Issues you face:
    1. While you could still use a regular expression to detect errors, it
    wouldn't tell you the invalid characters. You'd still have to loop through
    the string and extract unique characters that were illegal.
    2. Microsoft's validators were designed with a fixed error message property.
    You'd have to update the ErrorMessage property while preserving its original
    value. This is especially problematic on the client-side. You would build
    your error message string and assign it to the InnerHTML property of the
    <span> tag that represents the validator.
    3. Remember to write it all both on the client and server sides.

    --- Peter Blum
    www.PeterBlum.com
    Email:

    "Stephan Bour" <> wrote in message
    news:BC3582C9.E135%...
    > Hi,
    > I have a regular expression validator that checks a text box string:
    >
    > <asp:RegularExpressionValidator id="SeqFormat" runat="server"
    > Display="Static" ErrorMessage="Your sequence contains illegal characters"
    > ControlToValidate="Sequence"
    > ValidationExpression="^[AGTCagtc5678\n\s]{1,}$">
    >
    > I'd like to provide the user with a listing of the illegal characters that
    > triggered a failure of the validator. Do you know how to capture the

    illegal
    > characters and display them in a label?
    > Thanks,
    > Stephan.
    >
     
    Peter Blum, Jan 23, 2004
    #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. darrel
    Replies:
    5
    Views:
    355
    Andrew Jones
    Jul 2, 2004
  2. Craig G
    Replies:
    0
    Views:
    310
    Craig G
    Feb 24, 2005
  3. Wenjie

    if (f() != FAIL) or if (FAIL != f())?

    Wenjie, Jul 28, 2003, in forum: C Programming
    Replies:
    3
    Views:
    480
    E. Robert Tisdale
    Jul 31, 2003
  4. Replies:
    4
    Views:
    948
    Richter~9.6
    Feb 13, 2007
  5. Disc Magnet
    Replies:
    3
    Views:
    773
    David Thompson
    Mar 24, 2010
Loading...

Share This Page