Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Format Mask on textbox Date dd/mm/yyyy

Posted on 2006-11-19
9
Medium Priority
?
18,171 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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