C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Frequently used RegularExpressionvalidators


Posted Date: 29 Mar 2008    Resource Type: Articles    Category: .NET Framework

Posted By: victoria       Member Level: Gold
Rating:     Points: 10



In this article i am trying to explain the validation expression that can be used in frequently used validators




<td>emailAddress</td>
<td>
<asp:TextBox ID="Temail" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="invalid email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="Temail"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Only numbers</td>
<td>
<asp:TextBox ID="Tnumbers" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Only Numbers" ControlToValidate="Tnumbers" ValidationExpression="^[0-9]*$"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Indian Mobile Numbers</td>
<td>
<asp:TextBox ID="Tmoby1" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="please include+91 to your number" ControlToValidate="Tmoby1" ValidationExpression="^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}98(\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Indian Landline Numbers</td>
<td>
<asp:TextBox ID="Tmoby2" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ValidationExpression="\d{3,5}-\d{6,7}" ErrorMessage="areacode-phonenumber" ControlToValidate="Tmoby2"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>have only 6 elements in the text</td>
<td>
<asp:TextBox ID="Tonlysix" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ErrorMessage="only six chars" ControlToValidate="Tonlysix" ValidationExpression="\w{6,20}"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>numbers with or without special characters<p>LandLine:08655 1111111<br />
Mobile:+919844198441
</p></td>
<td>

<asp:TextBox ID="Tnumspl" runat="server" MaxLength=15></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" ValidationExpression="^\+?[\d\s]+\(?[\d\s]{10,}$" ErrorMessage="only numbers" ControlToValidate="Tnumspl"></asp:RegularExpressionValidator></td>

</tr>
<tr>
<td>Only Characters</td>
<td>
<asp:TextBox ID="Tchars" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server" ErrorMessage="Only Characters" ValidationExpression="^[a-zA-Z]*$" ControlToValidate="Tchars"></asp:RegularExpressionValidator></td>
</tr>
<tr><td colspan=3 align=center >
<asp:Button ID="Button1" runat="server" Text="Button" /></td></tr>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Counting a Hits in ASP.NET
Previous Resource: Implenting Inheritence and Shadowing Using Example Classes
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use