dimanche 30 avril 2017

how to set textbox width using javascript with checkbox checked

    $(function () {
        $("#chkShowPassword").bind("click", function () {

            var loginPW = $("[id*=loginPW]");

            if ($(this).is(":checked")) {


                loginPW.after('<input id = "txt_' + loginPW.attr("id") + '" type = "text" value = "' + loginPW.val() + '" />');
                loginPW.hide();
            } else {
                loginPW.val(loginPW.next().val());

                loginPW.next().remove();
                loginPW.show();
            }
        });
    });

here is the text box:

 <asp:TextBox CssClass="txtInput col-1" ID="loginPW" runat="server" TextMode="Password"></asp:TextBox>

and the checkbox is:

<asp:CheckBox ID="chkShowPassword" runat="server" Text="ShowPassword" />

suppose if the width of the text box is 100px, with the checkbox checked the textmode changes to singleline , but the width sets to the basic or default px.I tried with document.getelementbyid ... didn't worked .




Aucun commentaire:

Enregistrer un commentaire