File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static passwords

 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is "prototype"?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, in this portion of the code:


I use the two passwords in place of "something" and "somethingElse"?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I wrap this:

in another function?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, you can not call it from anything else then.

Eric
 
K Robert
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic