Insert a date in a text box or form field using ASP
Today's date:
Put this on line 1 (above the <head> tags):
<% Private Function Format(byVal expression, byVal strFormat) On Error Resume Next Select Case lcase( strFormat ) Case "general date" Format = FormatDateTime(expression, 0) Case "long date" Format = FormatDateTime(expression, 1) Case "short date" Format = FormatDateTime(expression, 2) Case Else Format = expression End Select On Error GoTo 0 End Function dim datetime datetime = Now() %>
Here is the code for the text box:
<input name="Date_field" type="text" value="<%=Format( datetime, "Short Date" )%>">