Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-09-2012, 03:58 PM   PM User | #1
Navya
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Navya is an unknown quantity at this point
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
Navya is offline   Reply With Quote
Old 10-09-2012, 06:53 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,395
Thanks: 18
Thanked 351 Times in 350 Posts
sunfighter is on a distinguished road
Code:
<script type="text/javascript">
       function checkPassword()
 {
	  password = document.getElementById('password').value;
	  var message = "The password entered was '"+password+"'.";
	  alert(message);
}
</script>
sunfighter is offline   Reply With Quote
Old 10-10-2012, 02:36 AM   PM User | #3
Navya
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Navya is an unknown quantity at this point
Thank You for the code. I really appreciate it!
Navya is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:05 AM.


Advertisement
Log in to turn off these ads.