OK, I'm pasting the code you IMd me here, because there are others who may be able to help with this as well.
<script src="signupcheck.js" language="JavaScript" type="text/javascript">
</script>
<Script language = javascript>
function Validate() {
Message = "";
Message = Message + Checkmyusername();
if (Message == "") {
return true;
}
else {
alert(Message)
return false;
}
}
function Checkmyusername() {
email = document.f1.myusername.value;
AtPos = email.indexOf("@");
StopPos = email.lastIndexOf(".");
Message = "";
if (email == "") {
Message = "Not a valid Email address" + "\n";
return Message;
}
if (AtPos == -1 || StopPos == -1) {
Message = "Not a valid email address" + "\n";
return Message;
}
if (StopPos < AtPos) {
Message = "Not a valid email address" + "\n";
return Message;
}
if (StopPos - AtPos == 1) {
Message = "Not a valid email address" + "\n";
return Message;
}
return Message;
}
</script>
<form name="f1" method="post" action="Signupcomplete.php" onSubmit="return Validate()" enctype = text/plain>
<tr>
<td>Fields marked with an asterisk (*) are mandatory</td>
</tr>
<tr><td height=20></td></tr>
<tr>
<td>Your Name*<small> (Enter First and Last Name)</small></td>
<td><input type="text" name="StudentName"></td>
</tr>
<tr>
<td>Email Address*<small> (This will be your User Name)</small></td>
<td><input type="text" name="myusername"></td>
</tr>
<tr>
<td>Type a password*</td>
<td> <input type="password" name="mypassword" maxlength="16" value="" /></td>
</tr>
<tr>
<td>I accept: <input type="checkbox" value="0" name="agree">
<p><input type="submit" name="Submit" value="Sign Up"></td>
</tr>
</td>
</center>
</table>
</form>
</body>
</html>
Some ideas here... The function that you really want to call is CheckMyUsername because Validate is not really pushing the information that you want it to, and you can handle everything within the CheckMyUsername function anyway. This, I believe is where your code is breaking.
after each line you need a ";" I have added these in your code above for you. To be honest, this depends on what browser you are using.. IE7 doesn't care about this, but it is still good practice regardless.
I believe (if I am not mistaken) that your variables need to be declared as such... so,
where you have variables you need to type
var foo = "bar";
one thing that you should do after each step run an alert just to see where you are breaking...
I also think you need to put the function call on the button itself and make it an on focus event, or onmousedown that triggers the function call and not onsubmit.
Hope this helps
Sage