• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

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.
0
reesecup09
Asked:
reesecup09
  • 4
  • 2
1 Solution
 
reesecup09Author Commented:
Is there a way to check for a completely blank form instead of an individual field?
0
 
basav_comCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now