In my rails application there’s a signup form which includes a DOB field.
The user’s age need not to be more than 18.How can i give validation for this one.
My dob format is mm/dd/yy
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The syntax for this is pretty fun, you could do something like this:
Turn your string into a date, add 18 years, and see if it is before or after today.
If you want to put this in a model validator, this railscast could be useful:
http://railscasts.com/episodes/211-validations-in-rails-3