CompareValidator using TextField with CalendarExtender with format dd/MM/yyyy HH:mm

Posted on 2008-10-29
Last Modified: 2008-12-09
Our project has a standard date format of dd/MM/yyyy HH:mm that I can not change.

I want to allow users to enter in a date into a textbox using the calendar extender.

Furthermore, we need to prevent them from selecting future dates.

Unfortunately the attached code does not work.

Suggestions / solutions?
  ErrorMessage="Can not pick future dates" 

Open in new window

Question by:Jonathan_Bride
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 22

Expert Comment

ID: 22841893
It is related to the current culture settings because the date format is determined by the culture information your application is using. You can change the culture information on a specific page by adding the culture information in the Page directive:
<%@ Page culture="here" %>
dd/MM/yyyy HH:mm looks like "en-GB", is it right? You can change try this:
<%@ Page culture="en-GB" %>

Author Comment

ID: 22845978

en-GB is unfortunately for me "31/10/2008 06:08:28". I need it without the last 28 / ss

LVL 22

Expert Comment

ID: 22850076
>>>en-GB is unfortunately for me "31/10/2008 06:08:28". I need it without the last 28 / ss

What do you get the value displayed? In the text box after user selects a date from the calendar?
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Author Comment

ID: 22852183
the display from user selection is (as per standard format)

dd/MM/yyyy HH:mm

Eng-Gb is

dd/MM/yyyyy HH:mm:ss

minor difference but it does not work as far as i am aware
LVL 22

Expert Comment

ID: 22852983
What if you set your CanlendarExtender's Format property to "dd/MM/yyyy HH:mm:ss", will that work for you?

Accepted Solution

Jonathan_Bride earned 0 total points
ID: 22863574
No, it can not have ":ss" at the end as the code behind in this solution automatically changes any date to dd/MM/yyyy HH:mm format

Found this regular expression that apparently I can use for custom validation

^(([0-2][1-9])|([1-3][0-1]))[\\.\\-\\/](([0][1-9])|([1][0-2]))[\\.\\-\\/](([2-3][0-9][0-9][0-9])) *(([0-9])|([0-1][0-9])|([2][0-3])):(([0-5][0-9]))$

If it does not, I will go with server side validation, instead of client-side.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question