Solved

Format Mask on textbox Date dd/mm/yyyy

Posted on 2006-11-19
9
17,847 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle null when using linq in this line 1 26
Calling stored proc in EDMX 11 23
Different Delete Messages 7 37
Why is some text in blue in Visual Studio? 6 22
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

947 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now