Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Age Validation #65

Open
nathanaskinner opened this issue Nov 10, 2020 · 0 comments
Open

Age Validation #65

nathanaskinner opened this issue Nov 10, 2020 · 0 comments

Comments

@nathanaskinner
Copy link

nathanaskinner commented Nov 10, 2020

We use a three field style Date of Birth pattern with a month select, day input, and year input.

I have a Javascript function to validate the age > 5 , < 110 (see below);

validateAge(year,month,day) {

    const max_year = new Date().getFullYear() - 110 ;
    const min_year = new Date().getFullYear() - 5 ;
    const _month = new Date().getMonth() + 1;
    const _day = new Date().getDay();

    const dateofbirthDate = new Date(year + "-"+month+"-"+day);
    const mindate = new Date( min_year+ '-'+_month+'-'+_day);
    const maxdate = new Date(max_year+ '-'+_month+'-'+_day);


    if(dateofbirthDate <= mindate && dateofbirthDate >= maxdate){
        return true;
    }
    else
        return false; 
}

We use bouncer for our validation, but how would I/could I incorporate this in to bouncer with customValidations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant