views:

44

answers:

2

Hi,

I do the validation through configuration files. But, RegexValidator does not work properly.

This Validator not disciplined even to unknown regular expression!!

For example, if I add a RegexValidator to field with regular expression '\d', It allow also Letters. it validate only first Character. Also, if I set more than 15 Characters the validation fails.

Do you know about this problem? Many thanks!!!

+1  A: 

I am not sure exactly what your problems is but i suspect that it can be solved by using Regex Anchors. You can read more about them here.

An example of there use would be as follows;

'\d' true if there is any digit anywhere in the test string
'^\d$' true if the string ONLY contains a single digit
'^\d*$' true if the string ONLY contains 0 or more digits
'^\d+$' true if the string ONLY contains 1 or more digits
'^\d{5}$' true if the string ONLY contains exactly 5 digits (i.e. a zip code)

Hope this helps guide you in the correct direction.

Patrick McMorris
A: 

Thanks, it really helps things work better! But I still have a problem if I put more than 15 numbers, validation fails, even though I write a format: ^(\d{1,20})$ Maybe you have an idea?

sarae