Solved

Javascript to check for a blank form

Posted on 2009-04-05
9
187 Views
Last Modified: 2012-05-06
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
Comment
Question by:reesecup09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 

Author Comment

by:reesecup09
ID: 24072435
Is there a way to check for a completely blank form instead of an individual field?
0
 
LVL 12

Accepted Solution

by:
basav_com earned 125 total points
ID: 24072500
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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
LVL 12

Expert Comment

by:basav_com
ID: 24072508
0
 

Author Comment

by:reesecup09
ID: 24072964
Will this check to see if no field has been completed?
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24073201
yes... check the tutorial for more understanding.
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
ID: 37169580
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

724 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