Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript password validation not working

    I have the following code that I can not figure out why the validation function is not being call. Any suggestions?
    <pre><?php #

    if (isset($_POST['submit']))
    { // Handle the form.
    //put the php here
    } // End of the main Submit conditional.
    else
    {
    ?>
    <SCRIPT LANGUAGE="JavaScript"></SCRIPT>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"
    name="ImaForm" onsubmit="return CheckMe()">
    <table>
    <tr>
    <td>Password:</td><td><input type="password" name="ownerpw" size="19"></td>
    </tr><tr>
    <td>Validate password:</td>
    <td><input type="password" name="ownerpw2" size="19"></td>
    </tr>
    </table>




    <input type="submit" value="Submit">
    </form>
    <?php
    }
    ?>

    </pre>

    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Javascript password validation not working

    Can you also post the CheckMe function you are calling?

    Are you sure it is not being called, or is it just not doing its job properly?

    You can test this by putting in
    alert ("This is a Javascript Alert"); as the first line of your function.
    Regards
    John



  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Javascript password validation not working

    <P ID="edit" class=small>(Edited by jscher2000 on 19-Feb-07 14:18. )</P>The src attribute appears to be missing from your <script> tag. Should look something like this:

    <code><script type="text/javascript" src="validationcode.js"></script></code>

    Added: Or, if it's inline script, you need to remove the comment tags when you post the script block in the Lounge to avoid having it removed from your post. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript password validation not working

    I must have made a mistake in posting. Here is the script in a text file.

    My alert never shows...
    Attached Files Attached Files
    • File Type: txt 1.txt (848 Bytes, 9 views)
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Javascript password validation not working

    I don't know whether you've discovered Firefox's Errors Console (Tools menu). When loading your page, it reports:

    <code>Error: unterminated string literal
    Source file: .../formval.html
    Line: __, Column: 10
    Source code:
    alert('Please check your password; the confirmation entry does not match.); </code>

    In other words, a closing ' is missing from the above statement. Fix that and the script works.

  6. #6
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Javascript password validation not working

    Thank you for the FireFox tip and the help getting this crazy thing to work. I appreciate both!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

Posting Permissions

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