Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for one of two static passwords

Status
Not open for further replies.

gabrielAllen

Programmer
Feb 14, 2001
19
0
0
US
I have a submit button that needs to check for either of two static passwords, which enables a submit button. Currently, I have one password that I create with:

Code:
var soPasswd = "Password1"; 
function getsoPasswd() 
{ 
return soPasswd; 
}

which is in a global *.js. And I have a function in a local page that calls this function to check the password like this:

Code:
function checkPassword(){ 
if (document.form.tfOtherJobTitle.value == window.parent.getsoPasswd() && document.form.checkBox.checked==true ) { 
document.form.submit.disabled = false; 
} else { 
document.form.submit.disabled = true; 
} 
}

How can I incorporate a 2nd password, so that there are two different passwords that the checkPassword () can identify?

*Also, I know that passwords should not be static, but this app is in house and I don't make the rules.
 
Change this:

Code:
if (document.form.tfOtherJobTitle.value == window.parent.getsoPasswd() && document.form.checkBox.checked==true ) {

to something like this:

Code:
var userPwd = document.forms['form'].elements['tfOtherJobTitle'].value;
if ((userPwd == window.parent.getsoPasswd() || userPwd == window.parent.getsoPasswd2())&& document.form.checkBox.checked==true ) {

(which assumes you'll have a getsoPasswd2 function)

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Code:
function checkPassword(){ 
if ([!](document.form.tfOtherJobTitle.value == password2 ||[/!]document.form.tfOtherJobTitle.value == window.parent.getsoPasswd()[!])[/!] && document.form.checkBox.checked==true ) { 
document.form.submit.disabled = false; 
} else { 
document.form.submit.disabled = true; 
} 
}

Is that what you mean?

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Of course, not only is Dan faster, but his use of the forms and elements collections should not be ignored!

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top