Java script form validation

The code below shows my simple java  form field validation script.
I would like to add a function that checks for the selection of a check box.
Can anyone assist?
<script type='text/javascript'>
function finalCheck(){
	// Make quick references to our fields
	var ship_dest = document.getElementById('ship_dest');
	// Check each input in the order that it appears in the form!
	if(madeSelection(ship_dest, "Please select a destination")){			
							return true;
					}		
	return false;
}
function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}
function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}
</script>

Open in new window

LVL 5
Neil_BradleyWeb UX/UI DeveloperAsked:
Who is Participating?
 
dimmergeekCommented:
try "if elem.checked==false"
0
 
Evan CutlerVolunteer Chief Information OfficerCommented:
I would need your HTML to see how you localized your combobox.....

that being said:
This article is a good resource:
http://www.webdevelopersnotes.com/tips/html/finding_the_value_of_a_checkbox.php3
0
 
Neil_BradleyWeb UX/UI DeveloperAuthor Commented:
Hi arcee123.
Here is the working form. http://gromit.utopia.co.nz/~ballochd/test.php
As you will see I need to add validation to the checkbox.
Thanks,
N
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
dimmergeekCommented:
if (document.getElementById("termsCheck").checked==false)
{
     alert(helperMsg);
     return false;
}

Open in new window

0
 
Neil_BradleyWeb UX/UI DeveloperAuthor Commented:
This is the code source I am using however there is no example of validating a select button.
http://www.tizag.com/javascriptT/javascriptform.php..

dimmergeeek, thanks for your posting however I am unsure how your script fits into my form.
N
0
 
Neil_BradleyWeb UX/UI DeveloperAuthor Commented:
Try this.
I think I am on the right track here but its not quite there yet.
http://www.ballochdaleestate.co.nz/test2.php
0
 
Neil_BradleyWeb UX/UI DeveloperAuthor Commented:
Thats got it.
Cheers for the assist.
Neil
0
 
dimmergeekCommented:
You're welcome!
Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.