Solved

Format Mask on textbox Date dd/mm/yyyy

Posted on 2006-11-19
9
17,939 Views
Last Modified: 2007-12-19
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.
0
Comment
Question by:RamyBouchra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17975129
Have a look at:
http://www.builderau.com.au/webdev/scripting/soa/Create_a_Web_form_data_format_mask_with_JavaScript/0,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.
0
 
LVL 3

Expert Comment

by:jay_gadhavi
ID: 17977451
0
 
LVL 6

Expert Comment

by:Niraj_Singh
ID: 17978976

 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 =
  @"^(([1-9])|(0[1-9])|(1[0-2]))\/((0[1-9])|([1-31]))\/((\d{2})|(\d{4}))$";

 this would solve your problem....
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RamyBouchra
ID: 17979085
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
0
 
LVL 3

Accepted Solution

by:
jay_gadhavi earned 500 total points
ID: 17985047
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.
Regards,
jay
0
 
LVL 3

Expert Comment

by:jay_gadhavi
ID: 17985072
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

http://www.codeave.com/javascript/code.asp?u_log=7044
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question