15 Feb 2014

Retrieving the value from password field using JS

Problem:
How to retrieve the value from password field.

 Code:

Note: The password should not visible to you even if you display then use this code.


 <html>
<head>
<script language="JavaScript">
function hemanth()
{
var a=document.f1.t1.value;
var i=0;
document.writeln("You entered value in password field is:");
for(i=0;i<a.length;i++)
{
document.writeln("*")
}
}
</script>
</head>
<body>
<form name="f1" onsubmit="hemanth()">
<center>
<table>
<tr>
<td>
Enter your password:
</td>
<td>
<input type="password" name="t1">
</td>
<tr>
<td>
</td>
<td>
<input type="submit" value="submit">
</td>
</tr>
</table>
</center>
</form>
</body>
</html>

No comments:

Post a Comment