Can I create a date separator control with a date separator for classic ASP

I used a calendar control to enter a date in a classic-ASP application. But calendar management is not keyboard friendly and takes longer to enter data. Therefore, later I added a simple text field with a date check. It is working fine. However, the user must also set the date separator. I want to put a date input field that comes with a predefined date format and separator so that the user simply types in numbers and a field, also causing a check.

How can i achieve this?

+1
source share
4 answers

Just use jQuery / javascript to mask the date text field. It automatically formats the date when the user enters values. Also forces a validation check as it works.

for example for jQuery plugins:

jquery date mask: http://digitalbush.com/projects/masked-input-plugin/

+4
source

You can always place three text fields with a separator as text (as on the old ASP classic site)

enter image description here

You need to separate the date in the response and then join it using DateSerial when publishing.

+2
source

When we created something similar in the past, we allowed the user to enter a date in the text box in several ways:

  • DDMMYYYY
  • D / M / YYYY
  • 0 (today)

When the form was submitted, we had a simple ASP function to convert DDMMYYYY to DD / MM / YYYY (the date string should be 8 characters, although since the assumption was 2 digits for DD, insert a separator, 2 for MM, etc.) and check that it is a valid date, and if formdate = 0 then formdate=now() rule.

You also need to add some JavaScript validation on the form. In the text box, add the onblur event to verify the same: either the entered 8 digits, or the valid date, or 0 - otherwise warn the user. (I would do it in jQuery if we reworked it today)

You can get useful information using Javascript "validation" to speed up data entry if you want, for example, if many dates entered are yesterday or tomorrow, allow -1 or +1, or data entry is always during the current month, but on another day, allow the user to simply enter the number - 15, and Javascript / jQuery converts the string to 03/15/2011.

+1
source

With HTML 5 ... textMode = "Date"

 <asp:TextBox ID="TextBoxDate" runat="server" CssClass="form-control" Width="561px" TextMode="Date"> </asp:TextBox> 
0
source

All Articles