₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,485 members, 8,512,138 topics. Date: Monday, 02 November 2026 at 09:40 PM

Toggle theme

Let's Play Around With Some Javascript - Webmasters - Nairaland

Nairaland Forum › Science/Technology › Webmasters › Let's Play Around With Some Javascript (501 Views)

1 Reply (Go Down)

Let's Play Around With Some Javascript by marin63(op):
I just took on a lesson and came of with something nice. Let's see how you can achieve this little snippet.
QUESTION: Create an input password with toggling ability from asterisk to normal text... I will post mine immediately after the first comment.
Re: Let's Play Around With Some Javascript by marin63(op): 6:42pm On May 07, 2015
hmm, lemme post mine then.

HTML MARKUP:

<html>
<head>
<title>Toggle Password Visibility</title>
</head>

<body>
<input type="password" placeholder="Insert Password" id="password">
<input type="button" value="Show Password..." id="button" onclick="visibility()">
</body>

</html>



JAVASCRIPT CODE:

function visibility(){

var type = $('#password').attr('type');

if(type == 'password'){
$('#password').attr('type', 'text');
$('#button').attr('value', 'Hide Password...');
}else if(type == 'text'){
$('#password').attr('type', 'password');
$('#button').attr('value', 'Show Password...');
}

}
Re: Let's Play Around With Some Javascript by Craigston: 6:56pm On May 07, 2015
I've not gone into JavaScript much but it may be done by toggling the 'type' attribute of the <input> element between 'password' and 'text'.
Re: Let's Play Around With Some Javascript by thewebcraft(m): 7:56pm On May 08, 2015
Craigston:
I've not gone into JavaScript much but it may be done by toggling the 'type' attribute of the <input> element between 'password' and 'text'.
This is just a simple jquery method
1 Reply

Snow Effect On Blog: How To Add Snow Falling Effect Javascript For Blogger • Post All Your Web Development Issues Here (php, Sql, Html, Javascript, Css) • 2 • 3 • 4

How Many Daily Unique Traffic Can Guarantee $100 A Month Google Ads • Need Help Nairaland • Sitemap Issues