help on field length validation using RangeValidator

Discussion in 'ASP .Net Web Controls' started by François Ligouy, Nov 2, 2004.

  1. On page 17 of module 7 ("Validating user input") of the document called
    "Developping Microsoft ASP.NET web applications using Visual Studio.NET"
    which is given to students who attend official training sessions on the
    subject, I've read subsequent characteristics concerning the Range Validator
    control :
    "RangeValidator has the following properties :
    "Minimum value", which specifies the minimum value of the valid range for
    numeric variables, or the minimum character length of the string for string
    variables
    "Maximum value", which specifies the maximum value of the valid range for
    numeric variables, or the maximum character length of the string for string
    variables

    The first usage ("valid range for numeric variables") works fine.

    I've tried to implement the second usage (minimum/maximum character length
    for string variables); unfortunately, this does'nt appear to work.
    Can someone let me know how to make it work or confirm to me what I srongly
    suspect : despite what the Microsoft document reads, validation of character
    length functionality can only be implemented using a custom validator.

    Thanks to anyone's help on the matter.
     
    François Ligouy, Nov 2, 2004
    #1
    1. Advertising

  2. Thanks for your answer, Peter. A RegularExpressionValidator is actually a
    better solution than having to write a custom validator. That will do fine
    for the intranet development I'm in for the time being, because everyone is
    using Internet Explorer in this one.
    For internet developments, I will seriously consider your "Professional
    Validation And More". I've just had a look at it and decided to bookmark it
    at once.



    "Peter Blum" <> a écrit dans le message de news:
    %23%...
    > That information is incorrect. RangeValidator does not check text length.
    >
    > Here are a couple of solutions:
    > 1. Use a RegularExpressionValidator with the expression set to:
    > ^[\S\s]{minimum, maximum}$
    > where minimum and maximum are replaced by your length limits
    >
    > 2. I built a replacement to Microsoft's validators, Professional
    > Validation And More (http://www.peterblum.com/vam/home.aspx). Amongst its
    > 22 validators is a TextLengthValidator with a couple of improvements over
    > the above solution:
    > - The error message can include tokens that are replaced by the minimum,
    > maximum and current length values. So its an interactive message.
    > - Its faster because it checks the actual text length instead of setting
    > up and running a regular expression. (Both server and client-side speed.)
    > - It, like all my validators, supports many more browsers when using
    > client-side validation.
    > I wrote Professional Validation And More because I found so many
    > limitations in Microsoft's validators that required writing custom code
    > and hacks. You can see what I learned about those limitations here:
    > http://www.peterblum.com/vam/valmain.aspx. It will help you plan your
    > site's validation design better.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "François Ligouy" <> wrote in message
    > news:...
    >> On page 17 of module 7 ("Validating user input") of the document called
    >> "Developping Microsoft ASP.NET web applications using Visual Studio.NET"
    >> which is given to students who attend official training sessions on the
    >> subject, I've read subsequent characteristics concerning the Range
    >> Validator control :
    >> "RangeValidator has the following properties :
    >> "Minimum value", which specifies the minimum value of the valid range for
    >> numeric variables, or the minimum character length of the string for
    >> string variables
    >> "Maximum value", which specifies the maximum value of the valid range for
    >> numeric variables, or the maximum character length of the string for
    >> string variables
    >>
    >> The first usage ("valid range for numeric variables") works fine.
    >>
    >> I've tried to implement the second usage (minimum/maximum character
    >> length for string variables); unfortunately, this does'nt appear to work.
    >> Can someone let me know how to make it work or confirm to me what I
    >> srongly suspect : despite what the Microsoft document reads, validation
    >> of character length functionality can only be implemented using a custom
    >> validator.
    >>
    >> Thanks to anyone's help on the matter.
    >>

    >
    >
     
    François Ligouy, Nov 3, 2004
    #2
    1. Advertising

  3. Scott Mitchell [MVP], Nov 23, 2004
    #3
    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. Lucas Tam

    Help: RangeValidator Not Working!

    Lucas Tam, Jan 31, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    963
    =?Utf-8?B?S29zdGFkaW4gS29zdG92?=
    Jan 31, 2005
  2. NotGiven
    Replies:
    3
    Views:
    389
    Michael D. Kersey
    May 13, 2004
  3. NotGiven
    Replies:
    3
    Views:
    332
    Michael D. Kersey
    May 13, 2004
  4. Sound
    Replies:
    2
    Views:
    503
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    501
Loading...

Share This Page