AIM: Write a JavaScript to show and hide password.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Show Password</title>
<script>
function DisplayPassword(){
var spbox = document.getElementById('sp')
if(spbox.checked){
document.getElementById('upwd').type = 'text'
}else{
document.getElementById('upwd').type = 'password'
}
}
</script>
</head>
<body>
<form name="login">
<input type="password" name="upwd" id="upwd" placeholder="Enter Password"><br><br>
<input type="checkbox" name="sp" id="sp" onchange="DisplayPassword()"> Show Password
</form>
</body>
</html>
<html lang="en">
<head>
<title>Show Password</title>
<script>
function DisplayPassword(){
var spbox = document.getElementById('sp')
if(spbox.checked){
document.getElementById('upwd').type = 'text'
}else{
document.getElementById('upwd').type = 'password'
}
}
</script>
</head>
<body>
<form name="login">
<input type="password" name="upwd" id="upwd" placeholder="Enter Password"><br><br>
<input type="checkbox" name="sp" id="sp" onchange="DisplayPassword()"> Show Password
</form>
</body>
</html>