Solved

Format Mask on textbox Date dd/mm/yyyy

Posted on 2006-11-19
9
17,828 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

9 Experts available now in Live!

Get 1:1 Help Now