473,385 Members | 2,274 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,385 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 9500
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.