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?
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why


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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

777 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