471,312 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,312 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 9382
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Piotr Pietrowski | last post: by
4 posts views Thread by Axel Dahmen | last post: by
3 posts views Thread by THaskell | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by R.A.M. | last post: by
1 post views Thread by R.A.M. | last post: by
1 post views Thread by Christian Heimes | last post: by

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.