wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Static passwords Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Static passwords" Watch "Static passwords" New topic
Author

Static passwords

K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
I have two passwords that I want to capture for use in my javascript, but I am not sure how to implement this properly.

Currently I have this to capture the value of one password:

and then I pass the function to another function to check for the value.

What do I need to do if I wanted to add another password and have the current functions I use check for one or the other?

Thanks in advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
why don't you do something like this

String.prototype.verfiyPassword = function(){
return (this=="something" || this=="somethingElse");
}

You would call it like

document.formName.elementName.value.verfiyPassword();

Eric
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
What is "prototype"?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

In a nutshell it's the "class" definition for a Javascript object. Adding a property to the prototype of an object type adds it to all instances of the class.

In this example, Eric has extended the String class with a new function.

This is an advanced, but very very useful concept in Javascript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
So, in this portion of the code:


I use the two passwords in place of "something" and "somethingElse"?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Yes.
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Can I wrap this:

in another function?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can, you can not call it from anything else then.

Eric
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
The reason I ask it that this would need to be a app-wide function and would need to be in a separate *.js. I am just not sure how to call it or implement this in the global *.js.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
calling this is no different than calling the function that you wrote. It is just a cleaner way of doing it since you can use it as a method rather than a function. You can easily do he return statement in yours with no problem.

I personally would use a server side language to do passwords since it is not even close to being secure, but that is apples to oranges.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static passwords
 
Similar Threads
Encryption in Java
if i store a password data from jsp to the database how to hide it from others seeing
Java Beans and JSP
Disabling copy and paste option in h:inputText and h:inputSecret
IntelliJ+CVS+SSH