Solved

Non submitting form

Posted on 2010-08-17
5
215 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
Comment Utility
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
Comment Utility
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
Comment Utility
I meant to have a semicolor on that line...

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

Expert Comment

by:sahanz
Comment Utility
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
Comment Utility
also u can try adding the function to the submit button onClick,
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now