How do I verify age using jQuery?

后端 未结 8 2048
故里飘歌
故里飘歌 2020-12-04 04:28

I need to validate if the age for a alcohol website. And what I need is all here. I\'m nearly there but I\'m not sure is correct . Locally doesn\'t work. I need the

8条回答
  •  遥遥无期
    2020-12-04 05:01

    Use http://timeago.yarp.com plugin.

    let them type in their date of birth and then you can use

    jQuery.timeago("2008-07-17");           //=> "3 years ago"
    

    if that number >= 21 they are of age

    for the cookie you can use this plugin https://github.com/carhartl/jquery-cookie

    $.cookie('the_cookie', 'the_value'); //set cookie
    $.cookie('the_cookie'); // read cookie
    

    SECOND EDIT: full source http://jsfiddle.net/bhdry/

提交回复
热议问题