CompareValidator can easily handle the request. Regular expressions are
complicated and have limitations like the inability to recognize a legal
date value.
The CompareValidator uses the current thread's CultureInfo
(System.Threading.Thread.CurrentThread.CurrentUICu lture) to determine the
date format.
You can set the culture with your desired date format in <@ Page culture= >
or on CurrentUICulture in Page_Load(). See the .net docs on the CultureInfo
class to learn how to create them and the culture IDs for your culture.
You can also modify a cultureInfo to set the desired format:
CultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"
CultureInfo.DateTimeFormat.DateSeparator = "/"
Hint: You cannot modify the CultureInfo object assigned by default to
CurrentUICulture. Clone it or create a new instance. These you can modify.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Do Quyet Tien" <ti************@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Use regular expression, check out a regex patter library here
www.regexlib.com
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:eh**************@TK2MSFTNGP11.phx.gbl... Is it possible to set the date format to dd/mm/yyyy?
Thanks
Regards
"Vko" <Vk*@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com... > Use a CompareValidator control, it was designed for.
>
> <asp:comparevalidator id="comparevalidator1" runat="server"
> controltovalidate="TextBox1" operator="DataTypeCheck"
> type="Date">*</asp:comparevalidator>
>
> "John" wrote:
>
> > Hi
> >
> > I have a web control text box on my webform which I want to use for
entering > > dates. Is there a way to validate this text box field for valid
> > dates?
May > > be using a validators such as regular expression validator?
> >
> > Thanks
> >
> > Regards
> >
> >
> >