Date Validation and Cultures

Small one this time but annoying. When using a CompareValidator to implement some simple date format checking with Operator=”DataTypeCheck” and Type=”Date. The CompareValidator is reliant on the active culture settings to validate the given string. The active culture if not specified by the application is taken from the clients region settings. This can result in the CompareValidator not validating or validating strings as dates depending on the clients settings. If you want to specify a single date format (and culture) you can do so either application wide (through setting the globalization culture tag of the web.config file e.g.
) or on a page by page basis by setting the UICulture and Culture attributes of the page e.g. <%@ Page UICulture=”en” Culture=”en-IE” %>. The different culture codes can be found here More info is provide by microsoft here.

%d bloggers like this: