[thelist] Javascript problem

David at softv.net David at softv.net
Mon Dec 3 09:28:42 CST 2001


Hi,

One possible problem is that JavaScript is CaSe SeNsItIvE. 
The line:

else if (emailto.indexof('@') == -1 || emailto.indexof('.')

should be:

else if ((emailto.indexOf('@') == -1) || (emailto.indexOf('.') == -1))

<%
David Mitchell
Web/Software Developer
david at sofTV.net
sofTV.net
www.sofTV.net
613.729.6400 x268
%>
www.IceRadio.ca
"Canada's Best Music on the Web"


-----Original Message-----
From: Lachlan Cannon [mailto:tiedefenderdelta6 at yahoo.com]
Sent: Monday, December 03, 2001 10:16 AM
To: thelist at lists.evolt.org
Subject: [thelist] Javascript problem


Hey everyone,

After staring at this for an hour trying to figure out what
was wrong, I throw myself at your mercy... or
javascriptliness or whatever it's called.

I'm trying to set up my own web based mail system (for
kicks and because I can), and I'm working on the client
side half at the moment. I'm using the following function
to make sure all the necessary fields are filled in,
correctly (or as correctly as I can figure out how to check
for), yet for some reason if the to field is filled in,
even if it doesn't meet the rules and nothing else does it
still submits the form.

function checkMail() {
var errors="";
var errorstart="Please make sure you have completed the
e-mail form correctly.\n The following errors were
detected:\n\n";
var
emailto=document.forms["mailform"].elements["emailto"].value;
var
subject=document.forms["mailform"].elements["subject"].value;
var body=document.forms["mailform"].elements["body"].value;
if (emailto == ""){
	errors+="You must supply an address in the \'to\'
field.\n";
}
else if (emailto.indexof('@') == -1 || emailto.indexof('.')
== -1) {
	errors+="You must supply only valid e-mail addresses.\n";
}
if (subject == "") {
	errors+="You must supply a subject.\n"
}
if (body == "") {
	errors+="You must supply a message to send.\n";
}
if (errors != "") {
alert (errorstart+errors);
return false;
}
else {
return true;
}
}

Oh, and improvements to the email checking are welcome too.
;)

TIA,

Lachlan Cannon
{Luminosity}

__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list