I am performing both clientside and serverside validation , clientside-jquery and serverside-asp.net
I am using custom validators for checking numeric textboxes.The issue is there are few textboxes that need to check for numeric data and length of the data and also digits after decimal.so i guess i cannot create a common onservervalidate function for all of them as their validation needs differ.
So do i need to use different validation controls for all of them ..can i call three different method on one onservervalidate…
any suggestions thanks
I am performing both clientside and serverside validation , clientside-jquery and serverside-asp.net I am
Share
You can use the regex class. Within that you only need one function to validate your data with all your requirements.
the regex class is a powerful class where u can define complex patterns that the string has to match. this is one of my simpler regex validator function for my page which returns a boolean if the string send in the parameter (pass) matches the pattern.
it works like this:
Dim pattern As String = “^\S{6}\S*$”
// in this line u define the pattern, ^ is the left end of the string, and $ is the right end
\S{6} is matching the first 6 chars of the string and accepts ANY chars except whitespace chars
\S* does nearly the same, but * means that it can be any number of chars ( again any chars except whitespace chars )
so effectivly this pattern does not accept whitespaces and requires the string to be at least 6 chars long
for a comprehensive guide u should read this :
http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial
and in ur case the regex pattern should be this : ^\d{10},\d{2}$
u can use the same pattern syntax for serverside validation via a function like this, or clientside by creating a customregex validator and using the pattern in the appropriate property.