If you don't expect lot of users to cheat - then, perform the validation in server side and show an error. You need to do so anyway as users can turn off javascript and bypass similar validation.
Thanks Shahed. This is an Intranet app and users don;t really have much control over a lot of things, including some browser setting changes. Server side validation was what I was thinking too but thought maybe adding something like a regular expression
validator could come in handy to search for occurence of at least of one alpha character ina addition to those special characters. Trying to avoid a trip to server just to validate a textbox.
That's what I was suggesting but not sure what the expression would look like:
at least on character, from a-z, A-Z, dashes, spaces and periods. This is validating a first/last name so can't start with dash, period or space, can't end with dash and space but can end with period (Someone Jr.)
NoBullMan
Participant
1019 Points
780 Posts
Text validation
Jan 03, 2013 08:02 PM|LINK
Hi,
i have a textbox that can have alpha (a-z, A-Z), dash, space and period. I used:
<asp:TextBox ID="tbFirstName" runat="server" CssClass="NormalSmall" Width="170" MaxLength="50" /> <ajaxtoolkit:FilteredTextBoxExtender ID="fteFirstName" runat="server" Enabled="True" FilterType="Custom,UppercaseLetters,LowercaseLetters" ValidChars="- ." TargetControlID="tbFirstName" />But I want to make sure I catch the string that is entirely made up of dash, space and period and does not include alpha.
Madhu1234
Participant
1380 Points
287 Posts
Re: Text validation
Jan 03, 2013 08:14 PM|LINK
Then mention only "Custom" in FilterType.
Check this examples for reference..
http://www.aspsnippets.com/Articles/ASPNet-AJAX-FilteredTextBoxExtender-Control-Example.aspx#.UOXzbOQ81c0
NoBullMan
Participant
1019 Points
780 Posts
Re: Text validation
Jan 03, 2013 08:23 PM|LINK
I can't see how specifying only Custom solves my problem. How do I stop user from specifying " --. .." as name?
"ABC" is valid, "aBc" is valid, "A-b.c " is valid but " - . -" is not (no alpha).
shahed.kazi
All-Star
17953 Points
3635 Posts
Re: Text validation
Jan 03, 2013 11:38 PM|LINK
If you don't expect lot of users to cheat - then, perform the validation in server side and show an error. You need to do so anyway as users can turn off javascript and bypass similar validation.
.NET World |Captcha Control
NoBullMan
Participant
1019 Points
780 Posts
Re: Text validation
Jan 04, 2013 06:42 PM|LINK
Thanks Shahed. This is an Intranet app and users don;t really have much control over a lot of things, including some browser setting changes. Server side validation was what I was thinking too but thought maybe adding something like a regular expression validator could come in handy to search for occurence of at least of one alpha character ina addition to those special characters. Trying to avoid a trip to server just to validate a textbox.
viddhi
Participant
1458 Points
378 Posts
Re: Text validation
Jan 04, 2013 08:34 PM|LINK
How about using a regular expression validator?
NoBullMan
Participant
1019 Points
780 Posts
Re: Text validation
Jan 04, 2013 09:02 PM|LINK
That's what I was suggesting but not sure what the expression would look like:
at least on character, from a-z, A-Z, dashes, spaces and periods. This is validating a first/last name so can't start with dash, period or space, can't end with dash and space but can end with period (Someone Jr.)
Pengzhen Son...
Star
8208 Points
845 Posts
Microsoft
Re: Text validation
Jan 10, 2013 10:14 AM|LINK
Hi,
I try writing the regex expression as follows:
^[a-zA-Z][-a-z A-z.]*[a-zA-z.]$
Hope it can help you.
Feedback to us
Develop and promote your apps in Windows Store