Jump to content

Valdate age on a form


SA Rob
 Share

Recommended Posts

Hi Folks,I have a form which allows players to enter thier Date of Birth (DOB) in this format YYYYMMDD and it with all the other information is stored in MySQLMy request is this - players who turn 19 before the 31/12/2011 may not submit an entry as they are considerd to old, and simultaneously the information on the form not submitted to MySQL.I would like a pop up to appear saying "your submission is unsuccesful as you do not satisfy the required age requirments"

Edited by SA Rob
Link to comment
Share on other sites

wouldn't you want to do this with Javascript? That way they'll know even before the form get's submitted. You could validate the age after that particular box get's filled in, or prevent the form from submitting entirely. Either way though, you didn't really make it seem clear what the actual problem is. Do you need help validating a particular date? The pop-up (more to do javascript, though)? Both? What do you have for code relevant to age validation?

Link to comment
Share on other sites

wouldn't you want to do this with Javascript? That way they'll know even before the form get's submitted. You could validate the age after that particular box get's filled in, or prevent the form from submitting entirely.
What if the user disables JavaScript. They'd be able to submit the form even though they're older than 19.
Link to comment
Share on other sites

wouldn't you want to do this with Javascript? That way they'll know even before the form get's submitted. You could validate the age after that particular box get's filled in, or prevent the form from submitting entirely. Either way though, you didn't really make it seem clear what the actual problem is. Do you need help validating a particular date? The pop-up (more to do javascript, though)? Both? What do you have for code relevant to age validation?
Hi,The player may not have turned 19 before the 30/12/2011 that is the requirement - I am not sure what else you mean by code relavent to age validation?I like the idea of age validation before submission - YES, that is when the players enters his date of birth the reply will be given- youre to old.I use a system called ABVFP to generate the form and thus not to sure of the php part never mind the javascript side of things.thanks for your help
Link to comment
Share on other sites

Hi,The player may not have turned 19 before the 30/12/2011 that is the requirement - I am not sure what else you mean by code relavent to age validation?I like the idea of age validation before submission - YES, that is when the players enters his date of birth the reply will be given- youre to old.I use a system called ABVFP to generate the form and thus not to sure of the php part never mind the javascript side of things.thanks for your help
As in, what have you tried? It seems pretty easy. Check their birth date vs. the current date and make sure that their birth date is > (cutoff date - 19 years). You would definitely want to handle this using timestamps rather than formatted dating. From there you can have additional error handling to redirect them to a message in case javascript was disabled. Edited by thescientist
Link to comment
Share on other sites

As in, what have you tried? It seems pretty easy. Check their birth date vs. the current date and make sure that their birth date is > (cutoff date - 19 years). You would definitely want to handle this using timestamps rather than formatted dating. From there you can have additional error handling to redirect them to a message in case javascript was disabled.
Thank you - I do see a thing called time stamps in the MySQL database - is this the same thing we are talking about.I feel like a bit of a dunce but I surpose this is also a way of learning.RegardsRob
Link to comment
Share on other sites

yes. a timestamp is the number of milliseconds from the epoch; 1/1/1970. Most languages have a date object that allows you to get the current timestamp, and gives you methods to extract the pretty formate of it, ie 12/21/2010, 13:24:05. You should be able to find out more about PHP and Javascripts date objects in the w3 tutorials.http://en.wikipedia.org/wiki/Timestamp

Link to comment
Share on other sites

you can use mktime to get the timstamp of given date ..as scintist said above

Edited by birbal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...