Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2013, 11:09 AM
Authorized User
 
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?
 
Old May 11th, 2013, 06:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
The Following User Says Thank You to Imar For This Useful Post:
nick1248 (May 11th, 2013)





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





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