Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6148681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:19:18+00:00 2026-05-23T19:19:18+00:00

I have this: <input type=password id=txtPassword name=txtPassword /> and I want to do something

  • 0

I have this:

<input type="password" id="txtPassword" name="txtPassword" />

and I want to do something like this:

var password = document.getElementById("<%= txtPassword.ClientID %>").value();

but it tells me “‘txtPassword’ is not declared.” I’ve tried this:

var pswd = $find('txtPassword').value();

but I get “‘null’ is null or not an object. So Then I tried this:

var pswd = $find('txtPassword').value();

but I got the same thing. My input control is located in this mess:

    <asp:Panel ID="pnlPassword" style="display: none" runat="server">
<div class="PasswordPopup">
            <div id="PopupHeader">&nbsp;</div>
            <div class="Controls">
                <center><table><tr>
                    <td>Please enter your password:</td><td><input type="password" id="txtPassword" name="txtPassword" /></td></tr>
                <tr><td>&nbsp;</td>
                    <td><asp:button name="btnOK" id="btnOK" runat="server" text="OK" />&nbsp;&nbsp;<asp:button id="btnCancel" runat="server" text="Cancel" /></td></tr></table></center>
            </div>
 </div>
</asp:Panel>

How can I reference that input control in my javascript function?

Thanks,

Jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:19:19+00:00Added an answer on May 23, 2026 at 7:19 pm

    Server side controls (i.e. runat=’server’) will have generated ids when the control is rendered in the HTML, while NON server side controls will be as is.

    With Quintin’s solution, you should be able to use Control.ClientID to get access to your control.

    The reason you were having trouble is syntax.

    Solution1 (Quintin’s):

    • Add runat=’server’ to your control
    • var password = document.getElementById(“<%= txtPassword.ClientID %>”).value;

    Solution2 (use jQuery):

    • jQuery does not need the find notation for named elements
    • var password = $(‘txtPassword’).value;

    Solution3 (use DOM):
    – var password = document.getElementById(‘txtPassword’).value;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this input form which goes like this: <input type=checkbox name=vehicle value=Bike />
I have this: <input type=text value=Enter Password class=password /> ... onclick/onfocus, I'd like to
Suppose I have a form like this: Name:<input type=text name=xxx id=name/> Type:<select> <option>xx</option> <option>xx</option>
i have a input field for entering password in a webpage: <input name=txtPassword type=text
In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input
I have this: $(document).ready(function() { $(input[type=button]).click(function () { $(#test).html(W3Schools); alert(Would submit: + $(this).siblings(input[type=text]).val()); $.ajax({
I have a login page with an input of type password I would like
I have input with password type. And I want to do simple thing. If
I have this form: <form name=form method=post> <div> <p> Problem Name: <input type=text size=20
I have already download and install this package to support HTML5 input type http://support.microsoft.com/kb/2468871

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.