Date format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In the below listed code, I can force the users to enter date in mm/dd/yy
format.
I tried the dataformat method. But it does no validation at all.


<asp:templatefield
HeaderText="Ist Installed On" >

<edititemtemplate>
<asp:TextBox

ID="gTextBox_dte_install1st" runat="server"
Text='<%# Bind("dte_install1st")%>'
OnChange="NumericValidation(this.id)">

</asp:TextBox>
</edititemtemplate>
 
Hello rkbnair,
In the below listed code, I can force the users to enter date in
mm/dd/yy
format.
I tried the dataformat method. But it does no validation at all.
<asp:templatefield HeaderText="Ist Installed On" >

<edititemtemplate>
<asp:TextBox
ID="gTextBox_dte_install1st" runat="server" Text='<%#
Bind("dte_install1st")%>' OnChange="NumericValidation(this.id)">

</asp:TextBox>
</edititemtemplate>

You could use a RegularExpressionValidator, or get yourself a license for
Peter's Date Package (http://www.peterblum.com).
 
Hello rkbnair,
If so, how will the expression code look like?

Without actually checking the date itself:

^\d{1,2}/\d{1,2}/\d{2}$

There are more complex expressions going around that actually check the entered
text for correctness (even check for leap years), but it would be better
to use a custom validator and parse the contents both clientside and server
side for that.

Jesse
 
In the below listed code, I can force the users to enter date in mm/dd/yy
Another bad internationalization practice :-)
What's wrong with a date picker?
 
Back
Top