SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Perth, Western Australia
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating javascript?

    First of all, is it possible to code Javascript in valid XHTML (Transitional)? I'm stuck with validating an encrypted password script. This is the page, and following that is the code in question.

    http://www.hexi-decimal.com/locked1.php

    Code:
    <script type="text/javascript">
    //Encrypted Password script- By Rob Heslop
    //Script featured on Dynamic Drive 
    //Visit http://www.dynamicdrive.com 
    
    function submitentry(){
    password = document.password1.password2.value.toLowerCase()
    username = document.password1.username2.value.toLowerCase()
    passcode = 1
    usercode = 1
    for(i = 0; i &lt; password.length; i++) {
    passcode *= password.charCodeAt(i);
    }
    for(x = 0; x &lt; username.length; x++) {
    usercode *= username.charCodeAt(x);
    }
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(usercode==16866649800&amp;&amp;passcode==1714036561020)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location=password+".php"}
    else{
    alert("That doesn't seem to be right.")}
    }
    </script>
    
    <center>
    <div class="login">
    <form name="password1" action="">
    Username:<br />
    <input type="text" name="username2" size="15" />
    <br /><br />
    Password:<br />
    <input type="password" name="password2" size="15" />
    <br /><br />
    <input type="button" value="Click" onClick="submitentry()" />
    </form>
    </div>
    </center>
    I can actually get it to validate; I should have been more specific. I validated it and then when I went back to test-run the script, it wouldn't work. Please help.
    POSTED WITH CARE BY JORDIE, WEBMISTRESS OF WWW.A-SPLODE.NET

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Convert the HTML entities back to their normal character representations (i.e. & amp; should just go back to &), then move your script into a separate .js file. Call the file like so:
    Code:
    <script type="text/javascript" src="/encrypt.js"></script>


Bookmarks

Posting Permissions

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