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
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help With Log-In Script

    Here is my script. It works on "usernames" with someone@someone.com, but does not work on someone.someone@someone.com. I know it is the period in between...right before @.

    Please let me know how to fix. thanks!







    <html>
    <head>
    <title>Login</title>

    <script lang="javascript" src="REMOVED URL FOR SECURITY PURPOSES"></script>
    <script lang="javascript">
    function login()
    {
    var qdb = new QClient();
    qdb.Authenticate(document.getElementById('qdbusername').value, document.getElementById('qdbpassword').value);
    qdb.GetTicket();
    if(qdb.displayErrorAlert("The username and/or password are not recognized. Please check your username and password and try again. "))
    {
    return(false);
    }

    var a = document.getElementById('qdbusername').value;
    var temp = new Array();
    temp = a.split('@');
    temp = a.split('.');




    switch(temp[1]){
    case 'com':
    var url = "URL 1"
    break;
    case 'net':
    var url = "URL 2"
    break;
    case 'org':
    var url = "URL 3"
    break;
    default : alert("Cannot find your username.");
    }



    /*window.location.href = "REMOVED URL";*/
    if (url.length > 4) {
    window.location.href = url;
    }else{
    alert ("The username or password you typed was incorrect.");
    }


    return(true);
    }
    </script>
    <link href="gwc.com" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    .style1 {
    color: #000000;
    font-weight: bold;
    }
    -->
    </style>
    </head>

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    Code:
     
    temp = "john.doe@anonymous.com";
    username = temp.split("@")[0];
    domain = temp.split("@")[1];
    domainname = domain.split(".")[0];
    domainsuffix = domain.split(".")[1];
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Only works with .com, .org etc. What about .co.uk etc?

    Code:
    <script type="text/javascript">
    
    var temp = "john.doe@anonymous.co.uk";  /// or .com
    var username = temp.split("@")[0];
    var domain = temp.split("@")[1];
    var domainname = domain.split(".")[0];
    var domainsuffix1 = domain.split(".")[1];
    var domainsuffix2 = domain.split(".")[2];
    if (domainsuffix2 == undefined) {
    var domainsuffix = domainsuffix1;
    }
    else {
    var domainsuffix = domainsuffix1 + "." + domainsuffix2;
    }
    
    </script>

  • #4
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    that is a good point.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #5
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the replies.

    where would you drop that code in the code above?

    thanks again

    PS: I am only a newbie when it comes to java. My friend, who wrote this java, is on a 3 week vacation but I needed this fixed ASAP. Thanks again!

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

    Replace this stuff with the code you have been given:-

    Code:
    var temp = new Array();
    temp = a.split('@');
    temp = a.split('.');
    switch(temp[1]){
    case 'com':
    var url = "URL 1"
    break; 
    case 'net':
    var url = "URL 2"
    break;
    case 'org':
    var url = "URL 3"
    break; 
    default : alert("Cannot find your username."); 
    }


  •  

    Posting Permissions

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