troubleshooting Question

Form Validation Not working, using switch statement

Avatar of Westside2004
Westside2004Flag for United States of America asked on
2 Comments2 Solutions197 ViewsLast Modified:

I have the following code, but for some reason it never calls my function

<script type="text/javascript">
function valForm(frmName){

switch(frmName) {

// the  search form
   case "t12":
   var startYear = document.form1.start_year.value;
   var endYear = document.form1.end_year.value;
   var startMonth = document.form1.start_month.value;
   var endMonth = document.form1.end_month.value;
         alert('"Start Year" cannot be greater then "End Year"');
          return false;
          alert('"Start Month" cannot be greater then "End Month"');
          return false;


Here is a snippet from the form

<table width="100%" border="1" cellpadding="8" cellspacing="0" class="table">
<form method="post" name="form1" action="reports.cfm?s=t12"  onSubmit="valForm(t12)">


Any help appreciated

Cem Türk
Senior Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros