472,989 Members | 3,131 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Does CompareValidator work for the date in dd-mmm-yyyy format?

Hi,

I wish to validate the date a user has entered against the format
dd-mmm-yyyy
using the CompareValidator, but it does not work.

Does anybody have a simple solution please?

Many thanks in advance.

Regards,
Cyberlotus

Nov 19 '05 #1
3 9478
Hi!
I think you can use a RegularExpressionValidator with
ValidationExpression="\d{2}-\d{2}-\d{4}"

Thanks,
Baren

"CyberLotus" wrote:
Hi,

I wish to validate the date a user has entered against the format
dd-mmm-yyyy
using the CompareValidator, but it does not work.

Does anybody have a simple solution please?

Many thanks in advance.

Regards,
Cyberlotus

Nov 19 '05 #2
Hi Baren,

Thanks for the quick response. But RegularExpressionValidator will validate
the date with the given format.
But I want to compare between 2 dates with the given format.

More elabrately, I have 2 textboxes. One is storing "From date" in
dd-mmm-yyyy format and the other one is storing "To date" in dd-mmm-yyyy
format. Now I want to compare these 2 dates and if "To date" is less than the
"From date" I wish to throw an error.

Please help me in achieving this.

Thanks a lot.

Regards,
Cyberlotus

"Baren" wrote:
Hi!
I think you can use a RegularExpressionValidator with
ValidationExpression="\d{2}-\d{2}-\d{4}"

Thanks,
Baren

"CyberLotus" wrote:
Hi,

I wish to validate the date a user has entered against the format
dd-mmm-yyyy
using the CompareValidator, but it does not work.

Does anybody have a simple solution please?

Many thanks in advance.

Regards,
Cyberlotus

Nov 19 '05 #3
Hi CyberLotus,

The CompareValidator and RangeValidator offer the Type=Date property
setting. However, its limited to "short date patterns". That means the month
is represented by 2 digits, not by text, which is what "mmm" means.

You have two choices:

1. Whenever the built in validators don't do the job, use the
CustomValidator and write the logic yourself. The DateTime.ParseExact()
method will help you convert to the format you want. You probably will have
to live without the client-side version unless you are prepared to do a lot
of javascript coding.

2. My Peter's Date Package (http://www.peterblum.com/datecontrols/home.aspx)
has a DateTextBox that supports the abbreviated month format. You establish
a short date pattern in the xDateTimeFormatInfo property like "dd-MM-yyyy"
and dateseparator = "-". (Note that I wrote two Ns in the short date
pattern). Then you set the xAllowMonthNames property to "Show". (After you
download the free trial version, locate these properties in the User's Guide
for details.)

Next, you use the validators I supply, which includes a Compare validator
for this formatting.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"CyberLotus" <Cy********@discussions.microsoft.com> wrote in message
news:1B**********************************@microsof t.com...
Hi,

I wish to validate the date a user has entered against the format
dd-mmm-yyyy
using the CompareValidator, but it does not work.

Does anybody have a simple solution please?

Many thanks in advance.

Regards,
Cyberlotus

Nov 19 '05 #4

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

Similar topics

6
by: Piotr Pietrowski | last post by:
Hello everybody, I have a *big* problem. I thought its not that big problem for you professionals... Anyway, I have a begin date which has 3 dropdown boxes (day/Month/Year). The same for the...
1
by: edi | last post by:
Hi, Are there any differences between CompareValidator.ControlToCompare and CompareValidator.ControlToValidate? For example if I have TextBox controls: TextBox1 and TextBox2 what are the...
4
by: Axel Dahmen | last post by:
Hi, I've got the same problem as described below. No answer found yet. Can someone please help? (I'm using .NET 1.0 on my development machine and 1.1 on my webserver. Like Susanna, I only get...
0
by: gauthier | last post by:
Hi, I'm developing a web application available in multiple languages. When we switch language (via a drop down list), we switch the culture of the current thread: ...
3
by: THaskell | last post by:
I am using a comparevalidator to make sure that a date for a scheduling app is not in the past. <asp:CompareValidator id="cvSD" runat="server" ControlToValidate="txtStartDate"...
2
by: tshad | last post by:
I am trying to check the date of my field to check if it is greater that today, but I am getting an error. I am using : <asp:CompareValidator runat="server"...
1
by: R.A.M. | last post by:
Hello, I am learning ASP.NET 2.0 and I have a problem with CompareValidator control. On .aspx page I have a control: Date of birth: <asp:TextBox ID="BirthDate" runat="server"...
1
by: R.A.M. | last post by:
Hi, I am learning .NET 2.0 and I have a problem with asp:CompareValidator. On .aspx page I have: Birth date: <asp:TextBox ID="BirthDate" runat="server" ValidationGroup="BirthDate"/> and it...
1
by: Jason | last post by:
I have a textbox that I want to validate a textbox for a date like "01/01/2000 03:00PM" The below validates nicely for 01/01/2000. What's the easiest way to do this in asp.net 2.0 / vb.net? ...
1
by: Christian Heimes | last post by:
Rick King schrieb: datetime.date is a C extension class. Subclassing of extension classes may not always work as you'd expect it. Christian
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.