Answer the question
In order to leave comments, you need to log in
Why does iphone skip age verification?
Hello!
I can't understand why iphone doesn't take into account the condition, but android does.
I have the following check for age
var bDay = ""+yearVal+"-"+monthVal+"-"+dayVal+"";
var checkAge = Math.floor((new Date().getTime() - new Date(bDay)) / (24 * 3600 * 365.25 * 1000));
if(checkAge < 18) {
$(".error").show();
return;
}
Answer the question
In order to leave comments, you need to log in
a) In order to avoid misunderstandings with the date format of the input string, substitute the parameters explicitly:
b) It is also useful to reduce the time to one value for comparison:
PS: In general, the age must be calculated for each component of the date, so as not to run into leap years:
var now = new Date();
var age = (now.getFullYear() - yearVal - ((now.getMonth() - (monthVal - 1) || now.getDate() - dayVal) < 0 ? 1 : 0));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question