Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looking for help with Javascript (please)

    I've been looking at free scripts but don't seem to be able to find what I need. Would anyone be willing to help via email or instant messenger? I'm in the U.S., eastern time zone.

    Problems I'm running into (besides the code itself) -
    1. can't find a solution specific to my needs
    2. available coding is too complex for what I need
    3. I'm only a beginner and don't have a good grasp at what I'm trying to accomplish although I've written some code (for this particular problem) but it doesn't work

    If anyone could help I would appreciate it. The main issues are -
    1. password validation where the login and passwords are stored in an array
    2. validating email addresses to verify that they contain an "@" and a "."
    3. validating a birthdate entry just to see if it's a real date, I'm only looking to see if the month entered is between 1 and 12, the day is between 1 and 31, and the year is equal to or less than the current year

    I can provide more detail on how it is to be set up if needed. Again, I'm not looking for advanced security measures or super-fancy scripts. Only rudimentary scripting that I can understand on my own (so I can learn from it). The majority of what I've seen is way out of my realm of understanding.

    I sincerely appreciate any help.

    Mark

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Are you looking for someone to make this for you? I'm sure you could get it done for the right price if you post in the work offers forum. If not, you should post your code you are having problems with. And passwords and loggins? Are you using server side for this?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    There are lots of free scripts out there which should get you started.

    Have a look for example at

    http://javascript.internet.com/forms/

    http://javascript.internet.com/forms/validate-date.html

    Thank you for saying that you would appreciate any help rather than
    discourteously thanking your benefactors in advance.

    As has been pointed out, you can only have secure login with password using server side languages such as PERL, PHP etc. JavaScript coding can easily be read by any passer-by and provides no protection at all.
    Last edited by Philip M; 12-18-2004 at 12:06 PM.

  • #4
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    progress (?) so far

    OK, I'll go ahead and embarass myself. Here's what I've got so far. You'll see what I mean by "not complicated". Right now when I run this, no matter what is typed in you still get the alert. It never gets a match with the user name and password in the array. I'm not looking for anything fancier than this. The only testing will be with either leaving the entries blank or by typing the exact data as seen in the array.

    I've got two forms on the page. The first form accpts the userid and password. Then you press the login button. I need to bang the info typed in against the array info. If it doesn't have the exact name and password it sends the alert. I don't even need to check for blank entries or numeric characters. Yes, this is a horrible example of coding, but this will never be used in a real world situation. If the userid and password match one of the two in the array, the the cursor needs to land in the first field of the second form, on the same page.

    var notvalid = "Please enter a valid login.";
    var users = new Array(2);
    users[0] = new Array("man1", "up", "nice", "Good_guy@msn.com", "06/15/1902");
    users[1] = new Array("man2", "down", "naughty", "nasty@aol.com", "02/15/1906")

    function first_validate(frm) {
    if (frm.userid.value != users[0][0]
    || frm.userid.value != users[1][0]) {
    alert(notvalid);
    document.form1.userid.focus();
    return false;
    } else {
    if ((frm.userid.value == users[0][0]
    && frm.password.value == users[0][1])
    || (frm.userid.value == users[1][0]
    && frm.password.value == users[1][1]))
    document.form2.name.focus();
    return true;
    }
    }

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your problem is here:

    Code:
    if (frm.userid.value != users[0][0]
    || frm.userid.value != users[1][0]) {
    In simple english it says if the input value does not match username one OR username two return false...

    Since you can only input one username, the condition will be met because there will always be one that does not match...

    What you want is: if the input value does not match username one AND username two return false...

    Change the OR operator ( || ) to an AND operator ( && ) here:

    Code:
    if (frm.userid.value != users[0][0]
    && frm.userid.value != users[1][0]) {
    .....Willy

    BTW: I often find that it helps to debug logic errors by reading the code in simple english as above...
    Last edited by Willy Duitt; 12-19-2004 at 02:35 AM.

  • #6
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the guidance!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •