Format Question

P

pmclinn

I have a textbox named "mydate" and I want to add an "onblur" event to
it that will format the text in this format:

dd-MMM-yy

the data entry people use this format in the text box:

dd/mm/yy
d/mm/yy....

I'm having a heck of a time trying to get this to work. Any help would
be appreciated.
 
D

darrel

I have a textbox named "mydate" and I want to add an "onblur" event to
it that will format the text in this format:

dd-MMM-yy

Is that because the date has to be entered in the format? If so, then you
want to either:

a) format this on the server side prior to entering into the DB

or

b) use a validator control to make sure data is entered in that format to
begin with.

You could reformat it in the field, but that would require javascript, and
there's no guarantee that the end-user would have that enabled, so you'd
still have to check for the format on the server side anyway.

-Darrel
 
P

Peter Blum

One of the challenges that you face with showing the abbreviated month name
is that the CompareValidator doesn't support it. CompareValidator handles
digits for months.

There are a few third party DateTextBoxes with popup calendars available
that may handle abbreviated month names. Mine, "Peter's Date Package"
(http://www.peterblum.com/datecontrols/home.aspx) definitely does. If you
choose to download a free trial version, here's how you will set it up.
1. Add the DateTextBox
2. Establish the format with the xDateTimeFormatInfo property described on
page 34 of the User's Guide. When you do this, you will set these values:
ShortDatePattern = "dd-MM-yy" (not MMM)
DateSeparator = "-"
3. Set the xAllowMonthNames property to "Show"
4. My stuff comes with validators to handle the unusual format. Add a
DateTextBoxValidator for that purpose.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top