Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 10th, 2013, 11:09 AM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default Regular Expression Validator - odd case?

Hi,
I'm using the regular expression validator (p. 306) to guard against a text box entry that is too long. The regular expression I'm using is "^.{1,20}$". This works quite well normally. However if I enter more than 20 characters in a text box AND the text in the textbox contains one or more carriage return characters (\n) the following occurs:
1. I obtain the expected notice that the expression is too long.
2. I shorten the expression to 20 or less characters and the validator continues to show that the expression is too long until I have erased all of the carriage return characters.

I have found jQuery expressions that can replace the carriage return characters with " " but I need to retain them and would like the length test to work even with the carriage return characters present. Is that possible?
Reply With Quote
  #2 (permalink)  
Old May 11th, 2013, 06:15 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

White space is treated differently which causes the behavior you're describing. Does one of the regular expressions from this page work for you: http://forums.asp.net/t/1689377.aspx/1 ?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
nick1248 (May 11th, 2013)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Validator on Multi-Line TextBox wagswvu General .NET 1 June 4th, 2008 09:24 AM
Regular Expression Validator displaying a label thomaswharmanjr26 C# 0 January 25th, 2008 03:38 PM
Validator expression Maxxim ASP.NET 1.0 and 1.1 Professional 1 December 3rd, 2006 07:07 AM
Regular expression validator PT C# 4 August 25th, 2005 07:50 AM
question regarding regular expression validator NewbieProg Classic ASP Basics 1 November 9th, 2004 08:49 AM



All times are GMT -4. The time now is 09:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.