Format Mask on textbox Date dd/mm/yyyy

Dear Experts.

I am using ASP.NET2.0, C#.
I want to make Format mask. on a textbox that only Accepts Date format dd/mm/yyyy throught JavaScript.

so please can you Help me.
Who is Participating?
U can use onkeypress event on the textbox where u enter the dd mm and yyyy.
with the onkeypress event call the javascript functiion which count the length of the textbox value and if it is valid then the number you have pressed should be show in the textbox and if the length like example dd is more then 2 then give the alert message.
I hope u understood.
Try to do.
Have a look at:,339024692,320273671,00.htm

Although to be perfectly honest I would recommend the datepicker instead - it's easier to work with, and far simpler if you are concerned with globalisation.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.


 you can do this through regular expressions. to validate the date  just drag and drop a regular expression validator and set the following property to it.
RegularExpressionValidator1.ValidationExpression =

 this would solve your problem....
RamyBouchraAuthor Commented:
Hi Experts,

Thanks for your reply.
But, I need a kind of masking for the date, like enter numbers only and for day just enter 2 numbers and for month two numbers only and year 4 numbers.

Thank You,
Steven Metias
U can also set the maximum length of the text box  like as
 <input type="text" name="testDateFormat5" size='10' maxlength="10"  onkeypress=".......">
U can use the following ref for you leangth validation
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.