Sunday, January 29, 2012

RegularExpression Validations in asp.net



for date validations:
<asp:RegularExpressionValidator
               ID="Regular" runat="server" ErrorMessage="Invalid date(yyyy/mm/dd)" ControlToValidate="dpRequestDate" Display="Dynamic" ValidationExpression="^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[1-9])|(1[0-9])|(2[0-3]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])))?))?$"></asp:RegularExpressionValidator>
                
 
It is for E-mail format(validation expression) :  \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* 

and it is for characters not no.s :
1       ^\d{3}\-\d{2}\-\d{4}$ ;  

2    ^[a-z]*$

No comments:

Post a Comment

Comments

Search

Custom Search
Protected by Copyscape Plagiarism Software