How do I verify age using jQuery?

后端 未结 8 2083
故里飘歌
故里飘歌 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 04:47

    $('.submit').click(function() {
    

    should be

    $('#submit').click(function() {
    

    $(".submit") refers to a CLASS and $("#submit") refers to an ID.

    and you'll have to add some logic for checking if the remember checkbox is checked, i think you attempted to, but weren't able to see if it was successful because the code never executed. I added the logic for you (simple if statement) and within that, you need to add the cookie creation code.

    if ($('#remember').is(":checked")) {
        $.cookie('age', age, { expires: 365 });
    } else {
        $.cookie('age', age);
    }
    

    (uses https://github.com/carhartl/jquery-cookie)

    http://jsfiddle.net/bhdry/45/

提交回复
热议问题