mardi 12 janvier 2016

Check checkbox when textbox have specific number of characters

Hi im trying to make that my checkbox checked when the user type 8 digits on my input textbox. Now i can make the checkbox checked when te user types but im new in this and can't figure it out. THX for the help.

<input id="thecheckbox" type="checkbox">
<input id="theinput" type="text">

    $("#theinput").keyup(function () {
    if ($(this).val() == "") {
        $("#thecheckbox").prop("checked", false);
    } else {
        $("#thecheckbox").prop("checked", true);
    }
});

$("#thecheckbox").change(function () {
    if (!$(this).is(':checked')) {
        $("#theinput").val("");
    }
});




Aucun commentaire:

Enregistrer un commentaire