
RichElliott
Top achievements
Rank 1
RichElliott
asked on 28 Jul 2008, 02:03 PM
Hi all,
I'm using ASPNET AJAX Q1 2008 in a C# Web Application. I need an input box where the user can type a file name that does not contain any of the characters that Microsoft Windows does not allow in a file name, specifically:
\ / : * ? " < > |
I still want to allow upper and lower case letters, numbers, and dashes. Can anyone tell me the best way to do this with RadMaskedTextBox or RadTextBox?
Thanks a bunch,
Rich Elliott
Tigard, Oregon
I'm using ASPNET AJAX Q1 2008 in a C# Web Application. I need an input box where the user can type a file name that does not contain any of the characters that Microsoft Windows does not allow in a file name, specifically:
\ / : * ? " < > |
I still want to allow upper and lower case letters, numbers, and dashes. Can anyone tell me the best way to do this with RadMaskedTextBox or RadTextBox?
Thanks a bunch,
Rich Elliott
Tigard, Oregon
4 Answers, 1 is accepted
0
Accepted
Hi RichElliott,
You can use the ASP.NET validation controls that are provided with ASP.NET. These controls enable you to check the user's input based on a pattern defined by a regular expression. Take a look at Validating ASP.NET Server Controls for a complete explanation of validation controls and how to use them in your ASP.NET pages.
Here is an example:
Do not hesitate to write us if you have any other questions.
All the best,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You can use the ASP.NET validation controls that are provided with ASP.NET. These controls enable you to check the user's input based on a pattern defined by a regular expression. Take a look at Validating ASP.NET Server Controls for a complete explanation of validation controls and how to use them in your ASP.NET pages.
Here is an example:
<asp:RegularExpressionValidator |
id="RegularExpressionValidator1" |
runat="server" |
ErrorMessage="Only gif or jpeg files are allowed!" |
ControlToValidate="RadTextBox1" |
ValidationExpression="((\w+)\$?)+(.gif|.GIF|.jpeg|.JPEG)$"> |
</asp:RegularExpressionValidator> |
Do not hesitate to write us if you have any other questions.
All the best,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

RichElliott
Top achievements
Rank 1
answered on 29 Jul 2008, 03:46 PM
Plamen,
Thanks! I am now using the following code which allows upper and lower case letters, numbers, dashes, spaces, and a couple other specific special characters.
Thanks again,
Rich Elliott
Thanks! I am now using the following code which allows upper and lower case letters, numbers, dashes, spaces, and a couple other specific special characters.
<asp:RegularExpressionValidator ID="validatorTimesheetNotes"
runat="server"
ControlToValidate="radtxtbox_TimesheetNotes"
ValidationExpression="^[a-zA-Z0-9'.;\s-]{1,499}$"
ErrorMessage="Special characters are not allowed.<br>Must be less than 500 characters."
Font-Size="Small">
</asp:RegularExpressionValidator>
Thanks again,
Rich Elliott
0

Simon
Top achievements
Rank 1
answered on 16 Aug 2008, 10:03 AM
Hello Rich
Also look at the KeyPress section of the help file.
They detail how to limit character based on their
keycode value. This may be simpler than RegEx
by just using a javascript event to limit characters
based on their ASCII values.
Regards,
Simon
Also look at the KeyPress section of the help file.
They detail how to limit character based on their
keycode value. This may be simpler than RegEx
by just using a javascript event to limit characters
based on their ASCII values.
Regards,
Simon
0

plamen
Top achievements
Rank 1
answered on 24 Oct 2008, 12:20 PM
hi
You can review the following blog post:
http://blogs.telerik.com/PlamenPeshev/Posts/08-10-23/Using_Regular_Expression_TextBox.aspx?ReturnURL=%2fPlamenPeshev%2fPosts.aspx
Regards...
<John:Peel />
You can review the following blog post:
http://blogs.telerik.com/PlamenPeshev/Posts/08-10-23/Using_Regular_Expression_TextBox.aspx?ReturnURL=%2fPlamenPeshev%2fPosts.aspx
Regards...
<John:Peel />