473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Validating dates

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
Nov 19 '05 #1
4 1469
Vko
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

Nov 19 '05 #2
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

Nov 19 '05 #3
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


Nov 19 '05 #4
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
> >
> >
> >



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark | last post by:
Hi, Im trying to validate a form, all the validating works apart from one field. This particular field must consist of the first 2 characters as letters, & the following 5 as numbers. And if it...
5
by: Steve | last post by:
I am currently trying to validate data in an access database. I need to verify that columns containing date information are in the format ddmmyyyy and columns containg time information are in the...
4
by: John Livermore | last post by:
In C# what is the best way to validate that a particular string entered by a user will actually convert to a date w/o using a try catch block or writing code to explicitly parse the string? Here...
0
by: Ante Perkovic | last post by:
Hi, 1. Is there a way to validate a date in, for example in d.m.yyyy format, using validator control? 2. I have 2 calendars on the page. I would like the page to PostBack when both dates are...
1
by: panche | last post by:
I'm developing a fairly simple user control that has two textboxes for date/time entry (a from date/time and a to date/time). One of my requirements is that there should be no button that sets...
11
by: tshad | last post by:
I have 4 dropdown boxes (fromDay, fromMonth, ToDay and ToMonth) I want to be able to test to make sure that the dates are valid and the the From dates are < the To dates. When I add the...
2
by: Patrick.O.Ige | last post by:
I'm using this CompareValidator to validate dates but my default its mm/dd/yyyy <asp:CompareValidator ControlToValidate="DOB" Display="Dynamic" Text="Invalid birth date!" Operator="DataTypeCheck"...
9
by: xian2 | last post by:
Hi All, I have two fields in my table that need validating in regards to each other. The field names are "TourStartDate" and "TourFinishDate" "TourStartDate" is validated with >Date() And...
1
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have a textBox Where I type date. I want to validate it. Im using customValidate controls. I have this function in my code behind page void DatesValidate(object source,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.