troubleshooting Question

Form Validation Not working, using switch statement

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

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;
 
if(endYear<startYear){
         alert('"Start Year" cannot be greater then "End Year"');
                  document.form1.start_year.focus();
          return false;
              }
                  
                  if(endMonth<startMonth){
          alert('"Start Month" cannot be greater then "End Month"');
                  document.form1.start_month.focus();
          return false;
              }          
               break;

            }
            
            
      };
</script>

------
Here is a snippet from the form

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

-------------

Any help appreciated

-ws
ASKER CERTIFIED SOLUTION
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