|
-
May 27th, 2003, 11:16 AM
#1
Thread Starter
Fanatic Member
Return(false);
This is not ending the submission of the form. What am I missing?
Code:
<script language="JavaScript">
<!--
function addAnother(form){
if(form.ckAddAnother.checked)
{
if(form.LName.value != "")
{
LName = form.addITSS.LName;
}
else
{
alert("Plase fill in a last name!");
form.LName.focus();
return(false);
}
if(form.FName.value != "")
{
FName = form.FName.value;
}
else
{
alert("Plase fill in a first name!");
form.FName.focus();
return(false);
}
if(form.Region.value != "")
{
Region = form.Region.value;
}
else
{
alert("Plase fill in a region!");
form.Region.focus();
return(false);
}
if(form.administration.value != "")
{
administration = form.administration.value;
}
else
{
alert("Plase fill in an Administration!");
form.administration.focus();
return(false);
}
if(form.title.value != "")
{
title = form.title.value;
}
else
{
alert("Plase fill in a title!");
form.title.focus();
return(false);
}
}
return(true);
}
-->
</script>
-
May 27th, 2003, 11:29 AM
#2
Frenzied Member
do you have this in your form tag
onSubmit="return addAnother(this);"
-
May 27th, 2003, 11:33 AM
#3
Thread Starter
Fanatic Member
this is what I have.
<form name="form" action="addITConf.asp" method="get" onSubmit="addAnother(this);">
-
May 27th, 2003, 11:34 AM
#4
Thread Starter
Fanatic Member
sorry, I did not see the return part. thanks!!!
-
May 27th, 2003, 11:44 AM
#5
Thread Starter
Fanatic Member
Well it works fine with the first if statement, but then if I fill in the last name, and do not fill in the first name, it will keep executing.
-
May 27th, 2003, 11:59 AM
#6
Frenzied Member
here's what i usually use
Code:
function validation(){
var msg='';
if(document.forms[0].fname.value==''){msg+='\n -First Name';}
if(document.forms[0].lname.value==''){msg+='\n -Last Name';}
if(document.forms[0].phone.value==''){msg+='\n -Phone #';}
if(document.forms[0].email.value==''){msg+='\n -Email';}
if(msg==''){
return true;
}else{
alert('You forgot to fill the following fields:\n\n' + msg);
return false;
}
}
and it works fine !
-
May 27th, 2003, 12:01 PM
#7
Thread Starter
Fanatic Member
thanks, I will give it a shot. So does Javascript exit after that first if else statement?
-
May 27th, 2003, 12:02 PM
#8
Frenzied Member
no, cuz i check all the fields, then i check if i return true or false !
good luck
-
May 27th, 2003, 12:05 PM
#9
Frenzied Member
i just looked at your function, and you have something wrong i think
the first check you put this
LName = form.addITSS.LName;
and all the other one you put
FName = form.FName.value;
should'nt be
FName = form.addITSS.FName;
-
May 28th, 2003, 10:23 AM
#10
Thread Starter
Fanatic Member
that was my problem the whole time. Thanks!
-
May 28th, 2003, 10:34 AM
#11
Frenzied Member
You also misspelled Please in all of the "Plase fill in a ..." messages. Looks like another case of Copy|Paste gotcha. How many times have I done that myself?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|