I had a similar requirement before to validate for age 18 and over.
I used a custom validator (i try to avoid regular expressions if i can)
<asp:CustomValidator ID="cvDOB" runat="server" ControlToValidate="pmDOB"
ClientValidationFunction="VAge"
ErrorMessage="Birth Date is under age 18."
ForeColor="Red">*</asp:CustomValidator>
Here is the javascript to check for age over 18
function VAge(obj, args) {
var today = new Date();
var today_year = today.getFullYear();
var value = Trim(args.Value);
value = value.replace("-", "/").replace(".", "/");
var splitDate = value.split("/");
var dob_year = splitDate[2];
var dob_day = splitDate[1];
var dob_month = splitDate[0];
var dob;
dob = new Date(dob_year, dob_month - 1, dob_day);
if ((dob_day == dob.getDate()) && (dob_month == (dob.getMonth() + 1)) && (dob_year == dob.getFullYear())) {
dob_month = dob_month - 1;
var age = today_year - dob_year;
var today_month = today.getMonth();
var today_day = today.getDate();
if (dob_month > today_month) { age = age - 1 }
else if (dob_month == today_month && today_day < dob_day) { age = age - 1 }
if (age < 18) {
args.IsValid = false;
return;
}
}
else {
args.IsValid = false;
return;
}
args.IsValid = true;
}