Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form being submitted despite having one empty field

Status
Not open for further replies.

akaballa

Programmer
Feb 2, 2007
8
CA
Hello,

I am creating a form. In this form I have this section with several options (radio buttons). Now I made it mandatory to select an option using the if statement. However, when I click 'ok' on the alert box, the message is still being sent. Here is the code:

if (!form.taskIssue[0].checked && !form.taskIssue [1].checked && !form.taskIssue[2].checked &&
!form.taskIssue[3].checked && !form.taskIssue[4].checked && !form.taskIssue[5].checked &&
!form.taskIssue[6].checked && !form.taskIssue[7].checked) {

alert("Please select an option for the 'Task/Issue' field. Thank you.");
return true;
}
 
Well ya beat me to it and posted in a new thread already.

As I said in the other post, you want to return false if there was a problem, not true.

If there is still a problem then you will need to show more code.


At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top