Regular expression to validate MMM-yyyy

Posted by Naseer under ASP.NET on 2/13/2014 | Points: 10 | Views : 3257 | Status : [Member] | Replies : 3
Hi Friends,

i need to validate Textbox in this format 'MMM-yyyy'(ex:Feb-2014),how can i do this with regular expression


kindly help me.




Responses

Posted by: Nadh123 on: 2/14/2014 [Member] Starter | Points: 25

Up
0
Down

2down votefavorite





I am working with ASP.net and C# . Now, I have developed a web application. I want to change the current theme to windows classic theme in Window7(IE8) because my design is disordered when other theme used. Could I change theme at run time? Could I do this OnPreInit() Event. Please help me .


Mahendra
91-9908699686

Naseer, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 3/6/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,
You can use the below regular expression to validate the Textbox.
^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$


http://jsbin.com/xuhixibi/1/edit?html,js,output

Thanks,
A2H
My Blog

Naseer, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 3/6/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
1)
^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$

2)
<asp:RegularExpressionValidator ID="regvalidateStartDate" runat="server" ControlToValidate="txtStartDate" ErrorMessage="Start Date should of DD-MMM-YYYY format" SetFocusOnError="True" Style="position: static" ValidationExpression="^([Jj][Aa][Nn]|[Ff][Ee][bB]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][u]l|[aA][Uu][gG]|[Ss][eE][pP]|[oO][Cc]|[Nn][oO][Vv]|[Dd][Ee][Cc])-(19|20)\d\d$" Enabled="false">*</asp:RegularExpressionValidator>

References:
http://www.geekzilla.co.uk/View653502BD-00B7-4012-9786-F941208F5F0C.htm
http://forums.asp.net/t/1115540.aspx?validate+date+dd+MMM+yy+using+Regular+Expression+Validator
http://www.codeproject.com/Questions/234109/Date-Validation-in-dd-MMM-yyyy-format
http://www.codeproject.com/Tips/80961/Validating-dates-in-dd-MMM-yyyy-format

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Naseer, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response