.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Text box validation using regular expression

Posted By: dotnetbubbles     Posted Date: October 22, 2011    Points:5   Category :ASP.Net
I have a textbox and have to use the regular expressions in asp.net


My text should not allow the spaces in first and last place. In between words it can allow.
that means: it should allow alphabets, numbers and all special characters.

Output should be:
-----------------

India Bangalore -valid
<space>India Bangalore<space> - not valid
!India bangalore - valid
India bangalore!@#$%- valid
India<space>Bangalore - valid

i.e : use can enter the spaces in between the words but not in first position and last position.

Java script also fine.

Thanks in advance.

Responses
Author: Narayanan             
Posted Date: October 24, 2011     Points: 20   

Hi,
try this
Hi,
try this
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ErrorMessage="RegularExpressionValidator" ControlToValidate="TextBox1"
ValidationExpression=".*"></asp:RegularExpressionValidator>

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Maverick             
Posted Date: November 18, 2011     Points: 20   

Hello,

Refer www.regexlib.com it will help you build the regex.

Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend