Pages

Sunday 2 February 2014

How to Show Hide Password Characters or Field without Any Plugin using jQuery

How to Show Hide Password Characters or Field without Any Plugin using jQuery 



<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <title>jQuery Show or Hide Password</title>
 <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js">
</script>
 <script type="text/javascript">
 $(function () {
 $('#showpwd').hide();
 $('#btnclick').click(function ()
{
 var txt = $('#btnclick').val() var pwd = $('#hidepwd').val();
 if (pwd.length > 0) { if (txt == 'Show Password')
 {
 $(this).val('Hide Password'); $('#showpwd').val($('#hidepwd').val()); 
$('#showpwd').show();
 $('#hidepwd').hide();
 return false;
 } else if (txt == 'Hide Password')
 {
 $(this).val('Show Password');
 $('#showpwd').hide();
 $('#hidepwd').show();
 return false;
 }
} else
 {
 alert('Plese Enter Password');
 return false;
 }
 });
 }) </script>
 </head>
 <body>
 <form id="form1">
 <div>
 <b>Enter Password: </b> <input type="password" id="hidepwd" /> <input type="text" id="showpwd" /> <input type="button" id="btnclick" value="Show Password" />
 </div>
 </form>
 </body>
 </html>





Enter Password:


No comments:

Post a Comment