Validating Password w/o script

  • Thread starter Thread starter Ernest Griffin
  • Start date Start date
E

Ernest Griffin

Does any one know of a method to use the range (or any) validator to
determine the minimum and maximum password length with out using JScript
(or any other scripting language) in an ASP.NET form?
 
There is no other way. Validating values is beyond the capabilities of HTML
and so *some* form of programming language is required.
 
Ernest Griffin said:
Does any one know of a method to use the range (or any) validator to
determine the minimum and maximum password length with out using JScript
(or any other scripting language) in an ASP.NET form?

At some point, you will have to use a programing language.

If you want, you can do it client-side, not server-side.

Ricky
 
I was hoping to use C# as the Server side validation process. My
concern is that we may have browsers that may not understand the
JavaScript. I wanted to utilize a method that is well accepted and used
within the community. This will test for minimum and maximum password
length. I know how to determine this within C# and the .Net Framework
-- I was hoping to utilize a validation component. It sounds like this
is not the case and I am going to be using server side code behind to
manage this. Thank you
 
Use the validation controls.
They provide both client side and server side validation automatically.
So if the client side validation doesn't work for whatever reason, you're
still covered.
 
You certainly can do it with the existing validators and no coding because
Regular Expressions can handle it.

Use the RegularExpressionValidator with this Expression where you replace
the numbers with the lengths you want for min and max:
^.{4,10}$

If you want a more powerful solution, my TextLengthValidator, part of my
"Professional Validation And More" product
(http://www.peterblum.com/vam/home.aspx) includes:
- The ability to show the current number of characters in the error message
itself. For example, "Keep it between 4 and 10 characters. You typed 12."
- Regular expressions are a far slower way to process over simply testing
the length of the string. My code uses the length of the string. (Server
side benefits more from this optimization due to the high volume of
traffic.)
- Numerous improvements to formatting the error message and tools to get the
user's attention.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Why would you use a Reg. Exp. validator, when a range validator does just
this? Also, a Reg. Exp. validator won't check a value, only the length of a
value, so 10 and 99 would both be ok.

What the OP was looking for was a server-side way of having the validator
work, in case the clients don't do JavaScript. All the .NET validation
controls will validate server side as well as client side in case the
clients don't do it.
 
Hi Scott,

I read the original posting differently.

It asks for the length of the text to be between a minimum and maximum. The
RangeValidator simply doesn't test length. It compares the value against the
Minimum and Maximum properties. For example, when you use RangeValidator set
to Type=String, Minimum="A" and Maximum="Bzzzzzzzzzzz" will report errors
for any string that starts with an uppercase C and all lowercase forms. If
you set Minimum="10" and Maximum="20" for Type=String, it will still do a
string comparison allowing any text that starts with "1".

A Regular Expression can test length and that's why I provided the
alternative answer.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top