Solved

Non submitting form

Posted on 2010-08-17
5
218 Views
Last Modified: 2013-11-19
On the right hand side, i have a form that is supposed to submit some data (see the picture upload form)

http://tinyurl.com/2827oon

any idea why this won't submit?
0
Comment
Question by:lvollmer
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:ploftin
ID: 33455997
Try replaceing your checkForm function with the one I attached.

Sincerely,
Philip Loftin
function checkForm(f) {
	// validate form first
    var result=autocheck(f);
    if(!result) return false;
    var err = '';

    var private = document.getElementById('verify_0');
	if((a5051c5b3e2ab952833c57e5e2e7250ef+adadc441098d2532ca90bb4f4641395f7!=private.value)) {
		err += 'Please enter the correct math answer for human verification\n\n';
	}

	var fld=document.getElementsByName("First");
	if(fld.value == '') {
		err += fieldname(fld) + ' is mandatory\n'; 
	}
	
	var fld=document.getElementsByName("Last");
	if(fld.value == '') {
		err += fieldname(fld) + ' is mandatory\n'; 
	}
	
	var fld=document.getElementsByName("Email");
	if(fld.value == '') {
		err += fieldname(fld) + ' is mandatory\n'; 
	}
	
	var fld=document.getElementsByName("Phone");
	if(fld.value == '') {
		err += fieldname(fld) + ' is mandatory\n'; 
	}
	
    if(err) {
		alert('Error!\n\n'+err+'\n\nPlease correct and try again.');
        return false;
    }
    return true;
}

Open in new window

0
 
LVL 3

Accepted Solution

by:
drcheap earned 500 total points
ID: 33456020
You have an error in your JavaScript field validation.

Line 312:
if((fld.type=='checkbox' && !fld.checked) || (fld.type!='checkbox' && (!fld || !fld.value))) err += fieldname(fld) + ' is mandatory\n';


This is trying to validate the "First name" field by using the following:
var fld=document.getElementsByName("First");

Your field is actually called "First name" as per this HTML:
<input name="First name" type="text" maxLength="20" mandatory="Y" value="First name"/>


Since you already have a reference to the form itself as "f" try using this instead:
var fld=f["First name"]


This same issue will come up with the Last name, Email, Phone, etc. fields as well.
0
 
LVL 3

Expert Comment

by:drcheap
ID: 33456025
I meant to have a semicolor on that line...

var fld=f["First name"];
0
 
LVL 1

Expert Comment

by:sahanz
ID: 33456113
In ur document take this function,

 function checkForm(f){
                // validate form first
                var result=autocheck(f);
                if(!result) return false;
                var err = '';
                var private = document.getElementById('verify_0');
if((a168ca2df08a8a9adc741f4b555ad049e+a9a723d7a69b1993837c87b0419ec2f9b!=private.value)) {
err += 'Please enter the correct math answer for human verification\n\n';
}
var fld=document.getElementsByName("First");
if(fld) {
 fld=fld[0];
if((fld.type=='checkbox' && !fld.checked) || (fld.type!='checkbox' && (!fld || !fld.value))) err += fieldname(fld) + ' is mandatory\n';
 
}
var fld=document.getElementsByName("Last");
if(fld) {
 fld=fld[0];
if((fld.type=='checkbox' && !fld.checked) || (fld.type!='checkbox' && (!fld || !fld.value))) err += fieldname(fld) + ' is mandatory\n';
 
}
var fld=document.getElementsByName("Email");
if(fld) {
 fld=fld[0];
if((fld.type=='checkbox' && !fld.checked) || (fld.type!='checkbox' && (!fld || !fld.value))) err += fieldname(fld) + ' is mandatory\n';
 
}
var fld=document.getElementsByName("Phone");
if(fld) {
 fld=fld[0];
if((fld.type=='checkbox' && !fld.checked) || (fld.type!='checkbox' && (!fld || !fld.value))) err += fieldname(fld) + ' is mandatory\n';
 
}
 
                if(err){
                    alert('Error!\n\n'+err+'\n\nPlease correct and try again.');
                    return false;
                }
                return true;
            }

instead of return true right before the last line try using.

document.forms["form_24"].submit();
0
 
LVL 1

Expert Comment

by:sahanz
ID: 33456124
also u can try adding the function to the submit button onClick,
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
insert text field data into html script 13 41
How to make footer stick to bottom 9 30
Mobile page Scrolling down when refreshing 4 32
innerHTML 7 19
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question