Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display password on a popup box when submit button is clicked

    Can anyone please provide the correct javascript code for displaying the password onto a popup box when submit button is clicked
    for eg.

    if the password is typed as "yourock" which would be displayed as asterisks, when the submit button is clicked a pop up box is opened and the password is displayed as a real text.
    The following is the html code that I wrote:

    Code:
    <?xml version = "1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns = "http://www.w3.org/1999/xhtml">
    <title> Page1 </title>
    <link href="external.css" rel="stylesheet" type="text/css" />
    <head>
    <script type="text/javascript"> 
           function checkPassword()
     {
    	  var password = myForm.elements["password"].value;
    	  var message = "The password entered was '"+password+"'.";
    	  alert(message);
    }
    </script>    
    </head>
    <body>
    	<h1> Login Details </h1>
    	<p> Please login with your details</p>
    	
    <form name = "myForm" action="" method="POST">
    	<table border >
    	<tr>
    		<td> <b>User id </b></td>
    		<td><input type="text" name="Userid" </td>
    	</tr>
    	<tr>
    		<td><b> Password </b></td>
    		<td><input type="password" name="password" value=""></td>
    	</tr>
    	</table>
    	<br>
    <input class = "submitbutton" type = "submit" value = "Submit" onclick = "return checkPassword()" />
    <input class = "helpbutton" type = "reset" value = "Help" />
    
    </form>
    </body>
    </html>
    I have the javascript code, but it is working only for html, not for xhtml page that I have, Please clarify.
    Thank You

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,303
    Thanks
    23
    Thanked 612 Times in 611 Posts
    Code:
    <script type="text/javascript">
           function checkPassword()
     {
    	  password = document.getElementById('password').value;
    	  var message = "The password entered was '"+password+"'.";
    	  alert(message);
    }
    </script>

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You for the code. I really appreciate it!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •