PDA

View Full Version : convert text in a textbox for password?



ImperialSpider
Jun 11th, 2005, 11:11 PM
Basically what I am looking for is a script that when you click a button, it changes the text in a text box to asterisks, AND also submits the information to the server, so it can be saved. Even if it does not send info to the server, if it can switch it, That would be good too. Can anyone help me with this script?

I am sure that lots of people have seen the Credit Card commercial on T.V. with Emmitt Smith and him putting in his password of "Catch-22" then clicking on a button, and the password automatically changes to asterisks (********) in the textbox.

How is this done? Is it js, ssl or what? If it is a ssl, can someone tell me what kind it would be? I would like to have something like that for a website of mine, where the user can create his password, and see it before he/she confirms it as the password by clicking on the "confirm" button.

I dont like having to enter my password twice to verify it, so I think that this would do the job better for me.


Thanks,

ImperialSpider

vwphillips
Jun 11th, 2005, 11:40 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

var Obj,PassWord,Star,Nu;

function Enter(){
Obj=document.getElementById('passw');
PassWord=Obj.value;
if (PassWord.length<8){
alert('Minimum of Eight Charactors');
return;
}
document.getElementById('mypassw').value=PassWord;
Star='*';
Nu=1;
Change();
}

function Change(){
Obj.value=Star+PassWord.substring(Nu,PassWord.length);
Star+='*';
Nu++;
if (Nu<PassWord.length){ setTimeout('Change()',500) }
else {
Obj.value=Star;
Obj.setAttribute('disabled','disabled');
Obj.style.backgroundColor='silver';
}
}

//-->
</script>
</head>

<body>
<input id="passw" size="10"><input type="hidden" id="mypassw" name="mypassw" size="10">
<input type="button" name="" value="Enter" onclick="Enter();" >
</body>

</html>

brandonH
Jun 12th, 2005, 02:25 AM
this isnt exactly what you are looking for, but it dispalys what you are typing into the password input box as you type.......



<input type=password id=pass onkeyup=confirm(this)><input type=text id=txt1>


<script language=javascript>
function confirm(pass){
document.getElementById('txt1').value=pass.value;
}
</script>


of course you dont have to use a text input box for confirmation, you can also just have it inserted in as plain text next to the password box.

figured this would be a nice alternative to a long script.

you can pass the value of what is created to the server....

ImperialSpider
Jun 12th, 2005, 10:21 PM
vwphillips,
That code was superb, it far exceeded my expectations, I like the way you put the delay in there. Way cool!

Brandon,
I liked yours too, I know I can use that in another application I am about to be taking on in the near future.

Thanks again to you both.


Imperial Spider

Truest
Feb 2nd, 2011, 06:18 AM
Awesome Question ImperialSspider. i was was wanting the Exact same thing which is how i found your Post on Google..

This is an awesome script VW.. How can this be made to work in Firefox browser? Firefox wont recognize the entry of characters, alpha numeric or otherwise.

..Oh and is there a line of script that would cause the Asterisks to change color and then disappear after entry?

Philip M
Feb 2nd, 2011, 07:23 AM
<form name = "myform">
Enter Password <input type = "text" name = "passwordA" style="display:inline">
<input type = "password" name = "passwordB" style="display:none">
<input type = "button" value = "Toggle Text/Password" onclick = "toggle()">
</form>

<script type = "text/javascript">
function toggle() {
if (document.myform.passwordA.style.display=="inline") {
document.myform.passwordA.style.display="none";
document.myform.passwordB.style.display="inline";
document.myform.passwordB.style.color = "red";
var tempA = document.myform.passwordA.value;
document.myform.passwordB.value = tempA;
}
else {
document.myform.passwordB.style.display="none";
document.myform.passwordA.style.display="inline";
var tempB = document.myform.passwordB.value;
document.myform.passwordA.value = tempB;
}
}

</script>

Submitting a form refreshes the page so the password will disappear at that moment.

Truest
Feb 4th, 2011, 10:14 AM
PhilipM Awesome reply and Im really Impressed at your rapid response..just Noticing this Thread is 7 years old.. Incredible..