Results 1 to 11 of 11

Thread: Return(false);

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    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>

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    do you have this in your form tag

    onSubmit="return addAnother(this);"

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    this is what I have.

    <form name="form" action="addITConf.asp" method="get" onSubmit="addAnother(this);">

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    sorry, I did not see the return part. thanks!!!

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    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.

  6. #6
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    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 !

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    thanks, I will give it a shot. So does Javascript exit after that first if else statement?

  8. #8
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    no, cuz i check all the fields, then i check if i return true or false !

    good luck

  9. #9
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    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;

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    that was my problem the whole time. Thanks!

  11. #11
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    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
  •  



Click Here to Expand Forum to Full Width