By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

problen with form validation not working

P: n/a
LRW
I'm trying to get the script to alert you of certain blank fields when
you submit the form, but it just doesn't work, and I can't see why. By
all appearances it should be working.
But I get no errors, and then you SUBMIT it just goes right on to the
next page completely bypassing the validation.
What am I doing wrong? What am I missing?
If someone could give me a clue, I'd appreciate it!

Below is the JS and the relavent parts of the form.
Thanks!!
Liam

<script language=JavaScript>
<!-- Begin
function ValidateE1() {
var FieldList = "";
if (document.f1.toemail.value.length < 2 ){
FieldList = "To Email\n";
}
if (document.f1.fromemail.value == "") {
FieldList = FieldList + "From Email\n";
}
if (document.f1.msg.value == "") {
FieldList = FieldList + "Message\n";
}
if (FieldList != "") {
alert("We did not get all the information we need from you.\n\n
Please fill in the following field(s):\n\n" + FieldList);
return false;
} else {
document.f1.submit();
}
}
// End -->
</script>
--SNIP--
<form name="f1" id="f1" method="post" action="emailerproc.bkk"
onSubmit="return ValidateE1();" >
--SNIP--
<td valign="top"><input name="toemail" id="toemail" type="text"
size="40">
<span class="labelBlue"><br>^-- Recipient's E-mail
address</span> </td>
--SNIP--
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee
LRW said:

I'm trying to get the script to alert you of certain blank fields when
you submit the form, but it just doesn't work, and I can't see why. By
all appearances it should be working.
But I get no errors, and then you SUBMIT it just goes right on to the
next page completely bypassing the validation.
What am I doing wrong? What am I missing?
If someone could give me a clue, I'd appreciate it!

Below is the JS and the relavent parts of the form.
When posting code, please reformat it to use fewer columns.
You can see what happens to your code when I include it in
my reply:


<script language=JavaScript>
<!-- Begin
function ValidateE1() {
var FieldList = "";
if (document.f1.toemail.value.length < 2 ){
FieldList = "To Email\n";
}
if (document.f1.fromemail.value == "") {
FieldList = FieldList + "From Email\n";
}
if (document.f1.msg.value == "") {
FieldList = FieldList + "Message\n";
}
if (FieldList != "") {
alert("We did not get all the information we need from you.\n\n
Please fill in the following field(s):\n\n" + FieldList);
return false;
} else {
document.f1.submit();
}
}
// End -->
</script>

I don't know what system you're using that didn't flag the
error. Netscape 7 caught it right away.
The problem is that the first line of your alert contains an
unterminated string.
You can't just continue string literals from line to line.

Use something like:

alert("We did not get all the information we need from you.\n\n" +
"Please fill in the following field(s):\n\n" + FieldList);

Jul 23 '05 #2

P: n/a
LRW
Lee <RE**************@cox.net> wrote in message news:<c8********@drn.newsguy.com>...
When posting code, please reformat it to use fewer columns.
You can see what happens to your code when I include it in
my reply:

--SNIP--

I don't know what system you're using that didn't flag the
error. Netscape 7 caught it right away.
The problem is that the first line of your alert contains an
unterminated string.
You can't just continue string literals from line to line.


I couldn't see what you were talking about "fewer columns" until I
replied to your message. I'm using deja.com for my newsreader, and the
display shows nice and fine until I go into edit mode and it shows all
the extra columns. Sorry.

I was using Editplus (an elaborite notepad basically) to write with
and Avant browser (a glorified Internet Explorer) to view with. I'm
chagrined that Netscape told you what the problem was but neither
Avant nor IE told me.
What I did was go back through and deleted all blank spaces and
carriage returns and respaced and carriaged returned where necessary,
and that did it. What I found weird, is in several places when I'd
"delete" nothing would change and I'd have to delete once or twice
before the next character would move. Sort of like there were
invisible characters...like unintentional carriage returns perhaps.

But, it works great now! Thanks for the help!!
Liam
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.