简体   繁体   中英

Get Textbox value with TextMode=“Password” in JavaScript

I have a Asp.net TextBox with TextMode="Password": <asp:TextBox ID="txtAuthPwd" runat="server" TextMode="Password"/>

I need to get the value of this TextBox from the javascript

<script type="text/javascript">
    function someFunc() {
        var pwd = document.getElementById("<%=txtAuthPwd.ClientID%>").value;
    }
</script>

But the value is always empty. Please help...

Please check my code as below and it's working.

<asp:TextBox ID="txtPwd" TextMode="Password" runat="server"></asp:TextBox><br />
<asp:Button ID="btnSubmit" Text="Click" runat="server" OnClientClick="return test();" />


<script language="javascript" type="text/javascript">
    function test() {
        var pwd = (document.getElementById("<%= txtPwd.ClientID %>").value);
        alert(pwd);
        return false;
    }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM