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
  • 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?
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

792 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