Jump to content

verify checkbox not working


learningcurve

Recommended Posts

Hi,

I have a form with a checkbox.  I want to require users to read the statement and check the box before they can submit form. 

Here is the checkbox from the form (form2.php):

<p><strong><input type="checkbox" id="certify" name="certify" value="Yes" <?php if ($pgdata['printed']=='Yes') echo 'checked'; ?> >  I verify that I have followed the proposal guidelines
above and that my proposal includes citations of relevant literature and a reference list in APA format, a discussion
of evidence of learning outcomes, and a description of how the session will be run.</strong></p>

 

Here is the code from the javascript page:

function stopWithAlert(msg,targ) {
window.alert(msg);
targ.focus();
return false;
}


function verifyForm() {
var requiredPeopleFields, pplErrs, a, b, c;
requiredPeopleFields = ["first_name", "last_name", "department", "institution", "city", "country", "office_phone", "email_address"];
pplErrs = peopleErrors(requiredPeopleFields);
if (pplErrs) { return stopWithAlert("Please fill in this presenter's "+pplErrs.name.replace("_", " ")+".", pplErrs); }

if (realForm.title.value==='') { return stopWithAlert("Please enter the title of this session.", realForm.title); }

if (CKEDITOR.instances.abstr.getData()==='') { return stopWithAlert("Please provide an abstract of your session.", CKEDITOR.instances.abstr); }

if (document.getElementById('requestedFormat1')) {
	for (a=1; a<=3; a++) {
		if (document.getElementById('requestedFormat'+a).selectedIndex===0) {
			return stopWithAlert("Please indicated your preferred presentation format in order of preference.", document.getElementById('requestedFormat'+a));
		} else {
			for (b=1; b<=3; b++) {
				if (a!==b && document.getElementById('requestedFormat'+a).selectedIndex===document.getElementById('requestedFormat'+b).selectedIndex) {
					return stopWithAlert("Please indicated your preferred presentation format in order of preference. You cannot choose the same format twice.", document.getElementById('requestedFormat'+a));
				}
			}
		}
	}
}

for (c=1; c<=3; c++) {
	if (realForm['keyword'+c].selectedIndex===0 || (realForm['keyword'+c].selectedIndex===realForm['keyword'+c].options.length-1 && realForm['keyword'+c+'_other']==='')) {
		return stopWithAlert("Please select at least three keywords that apply to this session.", realForm['keyword'+c]);
	}
}

if (realForm.paper && realForm.paper.value==='') { return stopWithAlert("Please attach your written proposal.", realForm.paper); }

if (!realForm.certify.checked) { return stopWithAlert("Please review your submission and then mark the checkbox at the bottom of the page."); }

//Otherwise, looks good!
return true;
}

 

I did not write the initial code - I only added the checkbox and the js line about certify that the checkbox is checked.  I do not get any errors and I can submit the form regardless of checkbox status.  I am clueless and not very knowledgeable at this point of either php or javascript.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.