pigmentarts
asked on
Validation for age using asp.net, How??????????????????
I need some validation for my form, i have a text box where you enter your age, I need some sort some validation which will not allow someone under 18 year of age!
Can someone help, thanks.
PS i am using asp.net vbscript.
Can someone help, thanks.
PS i am using asp.net vbscript.
ASKER
sorry i ment to say there enter there birth date no there age, so i need something that checks this date to see if they are over 18 years old.
well u can use a custom validator or u can use a javascript function to do the validation
ASKER
i need a custom validator, any example in vb for me?
ASKER
did it this way
<asp:CustomValidator ClientValidationFunction=' "dob" > DateTime.Now.AddYears(-18) ' ControlToValidate="dob" Display="Dynamic" EnableClientScript="true" ErrorMessage="you must be over 18" ID="dobValidator" runat="server" />
seems to work fine.
<asp:CustomValidator ClientValidationFunction='
seems to work fine.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i can not get the script to work i can not convert it.
Exception Details: System.Web.HttpException: The value '01/01/0001 00:00:00' of the ValueToCompare property of 'AgeCompareValidator' cannot be converted to type 'Date'.
Exception Details: System.Web.HttpException: The value '01/01/0001 00:00:00' of the ValueToCompare property of 'AgeCompareValidator' cannot be converted to type 'Date'.
ASKER
shovavnik
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="RangeValidat
ControlToValidate="TextBox