Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   help on field length validation using RangeValidator (http://www.velocityreviews.com/forums/t774657-help-on-field-length-validation-using-rangevalidator.html)

François Ligouy 11-02-2004 11:48 AM

help on field length validation using RangeValidator
 
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 11-03-2004 10:20 PM

Re: help on field length validation using RangeValidator
 
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" <PLBlum@Blum.info> a écrit dans le message de news:
%23%23RKnmbwEHA.3376@TK2MSFTNGP12.phx.gbl...
> 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: PLBlum@PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
>
> "François Ligouy" <fligouy@inutilehotmail.com> wrote in message
> news:eIa5hHNwEHA.3320@TK2MSFTNGP14.phx.gbl...
>> 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.
>>

>
>




Scott Mitchell [MVP] 11-23-2004 08:31 PM

Re: help on field length validation using RangeValidator
 
Francois, I also have a custom validation control that does just this:
http://aspnet.4guysfromrolla.com/articles/112404-1.aspx



--

Scott Mitchell
mitchell@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!


All times are GMT. The time now is 12:27 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.