Javascript to check for a blank form

Hi - I have an online employment application form that I uses CGI script to send the data to my email. I do not want a blank form to get submitted. I need some simple javascript that can check to see if all fields are empty and if so not to submit the form.  A window can pop up saying something like the form has not been completed. What is the best way to achieve this? Thank you.
reesecup09Asked:
Who is Participating?
 
basav_comConnect With a Mentor Commented:
You can do like this:


function checkscript() {
	for (i=0;i<4;i++) {
		box = document.example.elements[i];
		if (!box.value) {
			alert('You haven\'t filled in ' + box.name + '!');
			box.focus()
			return false;
		}
	}
	return true;
}

Open in new window

0
 
reesecup09Author Commented:
Is there a way to check for a completely blank form instead of an individual field?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
basav_comCommented:
0
 
reesecup09Author Commented:
Will this check to see if no field has been completed?
0
 
basav_comCommented:
yes... check the tutorial for more understanding.
0
 
CWS (haripriya)Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
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.