...

View Full Version : Need Help With Log-In Script



Gokooljapan
05-06-2008, 10:49 PM
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>

mjlorbet
05-07-2008, 02:24 AM
temp = "john.doe@anonymous.com";
username = temp.split("@")[0];
domain = temp.split("@")[1];
domainname = domain.split(".")[0];
domainsuffix = domain.split(".")[1];

Philip M
05-07-2008, 08:22 AM
Only works with .com, .org etc. What about .co.uk etc?


<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>

mjlorbet
05-07-2008, 02:56 PM
that is a good point.

Gokooljapan
05-07-2008, 03:23 PM
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!

Philip M
05-07-2008, 05:14 PM
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:-


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.");
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum