Computer problems,Computer help
*AX SOFT>>>Programming & Design

Hi, does anyone know the best way to create a javascript code, for a password between 5 and 10 characters?


if the password is less or more than 5 or 10 characters, the user is prompt to re-enter until a corrct one is given.

<html>
<head>
<!--
No matter which you select
as "best answer" - pick one.
-->
<script>
function get(eid) {
var d = document;
var r = d.getElementById(eid);
return r;
}

function chkPass(pw) {
return (4< pw.length &&
11 > pw.length )
}

function send() {
var pw = get('pass').value;
if (chkPass(pw)) {
// do your steps for a
// good password, e.g.,
// submit the form
}
else {
// do bad password steps
var msg = 'bad password: ' +
'length must be between 5 ' +
'and 10 characters.';
alert(msg);
}
}
</script>

</head>
<body>
<form>
Enter password:
<input type="password"
id="pass" />
<input type="button"
value="send password"
onclick="send();" />
</form>
</body>
</html>

Honestly, if you are trying to password protect a file or a section of your site, you shouldn't be using javascript. javascript is run on the client machine, which means they have full access to view the source of your code (i.e. they can see your password).

If you truly want to password protect a section, you should consider using either a server-side script or something like htaccess in Apache.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Is C++ important to know in Engineering?

    C++ is being used more and more with embedded systems. Even some real-time systems depend on it. Off hand, if you really know Java, I'd say stick with that language until you it becomes more...

  • Oracle 10g - Environment Variable - WINDOWS?

    What SID did you use when you set up Oracle? I think it defaults to ORCL. Try set ORACLE_SID=ORCL at the command prompt and if that works set it permanently via your control panel. If you can�...

  • Staring your own website?

    Since you don't' have much knowledge you could start with a blog. Try wordpress ...

  • Java Programming: List/Itterated Merge Sort?

    Just replace the arrays in this code with a java.util.List and then use the List's iterator in the for-loops. public class Mergesort { /** * The main method illustrates the use of ...

  • While statement?

    #include <iostream.h> int main() { short int x; cout <<(x)<<endl; //Most compilers automatically assume the variable is the large possible number unless defined. but the below ...

  • How do you make a myspace or website backround?

    Thats simple. All you have to do is go to hotfreelayouts.com and look over all of the different backgrounds that are availible. When you find the one that you want, copy the code and paste it at th...

  • [C#] How do I get the name of the current program's namespace as a string?

    Hello, Okay, now the question is a understandable. :) You have to recall that an application may or may not have an namespace, it is optional, but it is best to use it for organization and many ...

  • How do you "reinstall" Zwinky?

    i would leave zwinky alone i think it has spyware and all sorts of crap that you dont want

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster