title: Struts form automatically submitted when using validate() method
body: <p>I am using struts 1.2. My struts flow is working properly but when I am using validate() method of action form for validation. my form is automatically submitted. and this validation method get called.</p>
  
  <p>I am not sure this is normal behavior of struts or some configuration are missing in my application.</p>
  
  <p>Please help me to understand it.
  following are the config and code</p>
  
  <pre><code>&lt;action path="/Postaddd" 
              type="bseller.postadd.PostaddAction" 
              parameter="dispatch"
              scope="request"
              validate="true"
              name="PostadddForm"&gt;
          &lt;forward name="posterror" path="ordererror.page"/&gt;
          &lt;forward name="successPost" path="bseller.successPost.page"/&gt;  
  
      &lt;/action&gt;       public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
      {
  
  
          Logger  log= Logger.getLogger("BSELLER_APPLICATION");
          log.info("validate method called");
          ActionErrors errors = new ActionErrors();
  
            log.info("Email Id: " + getEmailid()); 
            if(!Validation.isValidEmailAddress(getEmailid()))
                    {
                errors.add("emailid", new ActionMessage("prompt.email.error"));
                    }
            if(!Validation.isPhoneNumberValid(getMobile()))
            {
                errors.add("mobile", new ActionMessage("prompt.contactno.error"));
            }
  
            if(!Validation.isNumeric(getPrice()))
            {
                errors.add("price", new ActionMessage("prompt.price.error"));
            }
  
  
          return errors;
      }
  </code></pre>
  
  <p>///////////////</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" language="java"%&gt;
  &lt;%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display" %&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%&gt;
  &lt;%@ taglib uri="/WEB-INF/c.tld" prefix="c"%&gt;
  
  &lt;%@ page import="bseller.utils.*" %&gt;
  
  &lt;%@ page import="java.util.*" %&gt;
  
  &lt;%@page import="bseller.utils.CategorydetailObject"%&gt;
  &lt;%@page import="org.apache.struts.taglib.logic.IterateTag"%&gt;&lt;head&gt;
  &lt;title&gt;&lt;bean:message key="homepage.title" /&gt;&lt;/title&gt;
  &lt;html:base /&gt;
  &lt;style type="text/css"&gt;
  @import url("&lt;%=request.getContextPath()%&gt;/css/main.css");
  @import url("&lt;%=request.getContextPath()%&gt;/css/submitpost.css");
  
  &lt;/style&gt;
  
  &lt;script language="javascript" src="jquery_mini.js"&gt;&lt;/script&gt;
  &lt;script language="javascript" src="jquery.dimensions.js"&gt;&lt;/script&gt;
  &lt;script language="javascript" src="js/Ajax_Function.js"&gt;&lt;/script&gt;
  &lt;script language="javascript"&gt;
  
  
  
      var name = "#floatMenu";
  
  
      var menuYloc = null;
  
          $(document).ready(function(){
  
              menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
              $(window).scroll(function () { 
                  offset = menuYloc+$(document).scrollTop()+"px";
                  $(name).animate({top:offset},{duration:500,queue:false});
              });
          }); 
       &lt;/script&gt;
       &lt;script&gt;
       function ret_home()
       {
       alert("home");
       return false;
       }
       function ret_aboutus()
       {
       alert("about us");
       return false;
       }
       function ret_contactus()
       {
       alert("contact us");
       return false;
       }
  
       function getSubcatValue(categoryValue)
       {
       //alert(document.getElementById("categorySelect").Value);
       document.getElementById("categorySelect").Value =categoryValue;
       //alert(document.getElementById("categorySelect").Value);
        //alert(categoryValue);
        //var data="catvalue="+categoryValue;
        //alert(data);
        //datafromajax="";
       // alert("before1"+datafromajax);
        var url="Subcategory_Ajax.jsp?catvalue="+categoryValue;
        sendRequest(url);
        //alert("after"+datafromajax);
        //datafromajax="";
        document.getElementById("categorySelect").Value="";
       }
  
       /*function setUploadImageOption(ordertype);
       {
  
        if(ordertype=="Required")
        {
            //document.getElementById("UploadImage").visible= false;
            document.getElementById('UploadImage').style.visibility = 'hidden'; 
        }
       }*/
  
       function onchangeSubcat(subcatValue)
       {
        // alert(subcatValue);
        //alert(document.getElementById("subCatSelect").Value);
         document.getElementById("subCatSelect").Value =subcatValue;
         //alert(document.getElementById("subCatSelect").Value);
         //subcatValue=subcatValue;
       }
  
  
  
       //populatedropdown
       &lt;/script&gt;
  
  
  
  &lt;style type="text/css"&gt;
  body {
  
      height:2000px;
      color:#111;
      font:10px "Lucida Grande", "Lucida Sans", "Trebuchet MS", verdana, sans-serif;
      }
      #floatMenu {
          position:absolute;
          top:200px;
          left:55%;
          margin-left:235px;
          width:200px;
          }
          #floatMenu ul {
              margin-bottom:20px;
              }
              #floatMenu ul li a {
                  display:block;
                  border:1px solid #999;
                  background-color:#000;
                  background:'images/tab_bg1.gif'
                  border-left:6px solid #999;
                  text-decoration:none;
                  color:#ccc;
                  padding:5px 5px 5px 25px;
              }
              #floatMenu ul li a:hover {
                  color:#fff;
                  background-color:#333333;
              }
              #floatMenu ul.menu1 li a:hover {
                  border-color:#09f;
              }
              #floatMenu ul.menu2 li a:hover {
                  border-color:#9f0;
              }
              #floatMenu ul.menu3 li a:hover {
                  border-color:#f09;
              }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
  &lt;span id="er"&gt;&lt;/span&gt;
  &lt;%!
  
  List l;   
  HashMap&lt;String ,ArrayList&lt;CategorydetailObject&gt;&gt; hm =null; %&gt;
  
  
  &lt;%
   try
  {
  hm =(HashMap&lt;String ,ArrayList&lt;CategorydetailObject&gt;&gt;)config.getServletContext().getAttribute("PRODUCTS");
  }
  catch(Exception e)
  {
  }
  %&gt;
  &lt;input type="hidden" name="subcatfromajax" id="subcatfromajax"&gt;&lt;/input&gt;
  &lt;DIV class=city&gt;&lt;DIV id=welcome&gt;&lt;/DIV&gt;&lt;DIV id=main&gt;&lt;DIV id=block&gt;&lt;DIV id=header&gt;&lt;font size=4 color=blue &gt;
  Post Your Advertisement&lt;/DIV&gt;&lt;DIV class=blank5&gt;&lt;/DIV&gt;&lt;DIV class=blank5&gt;&lt;/DIV&gt;
  
  &lt;html:messages id="" /&gt;
  &lt;html:form action="/Postaddd.do?dispatch=submitPost" method="post" enctype="multipart/form-data" &gt;
  &lt;TABLE cellSpacing=0 cellPadding=0 width='98%'background='images/background_city.gif' border=0&gt;&lt;TBODY&gt;
      &lt;TR&gt; 
      &lt;TD&gt;&lt;div class="post_ad_fonts"&gt;Email&lt;/div&gt;&lt;div style="float:left"&gt;
    &lt;input style="width:162px" type="text" maxlength="64" name="emailid" id="emailid" class="post_ad_field" value='' /&gt;  
    &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
    &lt;/TD&gt;
      &lt;/TR&gt;
  
  
      &lt;TR&gt; 
  
      &lt;TD&gt;&lt;DIV id=bb1&gt;&lt;div class="post_ad_fonts"&gt;City&lt;/div&gt;&lt;div style="float:left"&gt;
  &lt;select class="post_ad_field" style="width:165px" name='citySelectBox' id='citySelectBox'&gt;
  &lt;option id='0' name='0' value='0'&gt;Select City&lt;/option&gt;
  &lt;option name='22' id='22' value='Ahmedabad' &gt;Ahmedabad&lt;/option&gt;&lt;option name='211001' id='211001' value='Allahabad' &gt;Allahabad&lt;/option&gt;&lt;option name='23' id='23' value='Bangalore' &gt;Bangalore&lt;/option&gt;&lt;option name='462001' id='462001' value='Bhopal' &gt;Bhopal&lt;/option&gt;&lt;option name='24' id='24' value='Chandigarh' &gt;Chandigarh&lt;/option&gt;&lt;option name='25' id='25' value='Chennai' &gt;Chennai&lt;/option&gt;&lt;option name='26' id='26' value='Coimbatore' &gt;Coimbatore&lt;/option&gt;&lt;option name='27' id='27' value='Delhi' &gt;Delhi&lt;/option&gt;&lt;option name='403108' id='403108' value='Goa' &gt;Goa&lt;/option&gt;&lt;option name='132222' id='132222' value='Gurgaon' &gt;Gurgaon&lt;/option&gt;&lt;option name='580020' id='580020' value='Hubli' &gt;Hubli&lt;/option&gt;&lt;option name='28' id='28' value='Hyderabad' &gt;Hyderabad&lt;/option&gt;&lt;option name='142222' id='142222' value='Indore' &gt;Indore&lt;/option&gt;&lt;option name='152222' id='152222' value='Jaipur' &gt;Jaipur&lt;/option&gt;&lt;option name='144001' id='144001' value='Jalandhar' &gt;Jalandhar&lt;/option&gt;&lt;option name='831001' id='831001' value='Jamshedpur' &gt;Jamshedpur&lt;/option&gt;&lt;option name='421301' id='421301' value='Kalyan' &gt;Kalyan&lt;/option&gt;&lt;option name='208001' id='208001' value='Kanpur' &gt;Kanpur&lt;/option&gt;&lt;option name='29' id='29' value='Kochi' &gt;Kochi&lt;/option&gt;&lt;option name='30' id='30' value='Kolkata' &gt;Kolkata&lt;/option&gt;&lt;option name='162222' id='162222' value='Lucknow' &gt;Lucknow&lt;/option&gt;&lt;option name='141001' id='141001' value='Ludhiana' &gt;Ludhiana&lt;/option&gt;&lt;option name='625001' id='625001' value='Madurai' &gt;Madurai&lt;/option&gt;&lt;option name='575001' id='575001' value='Mangalore' &gt;Mangalore&lt;/option&gt;&lt;option name='31' id='31' value='Mumbai' &gt;Mumbai&lt;/option&gt;&lt;option name='32' id='32' value='Mysore' &gt;Mysore&lt;/option&gt;&lt;option name='172222' id='172222' value='Nagpur' &gt;Nagpur&lt;/option&gt;&lt;option name='422001' id='422001' value='Nashik' &gt;Nashik&lt;/option&gt;&lt;option name='400701' id='400701' value='NaviMumbai' &gt;NaviMumbai&lt;/option&gt;&lt;option name='201301' id='201301' value='Noida' selected&gt;Noida&lt;/option&gt;&lt;option name='800001' id='800001' value='Patna' &gt;Patna&lt;/option&gt;&lt;option name='33' id='33' value='Pune' &gt;Pune&lt;/option&gt;&lt;option name='360001' id='360001' value='Rajkot' &gt;Rajkot&lt;/option&gt;&lt;option name='182222' id='182222' value='Surat' &gt;Surat&lt;/option&gt;&lt;option name='400601' id='400601' value='Thane' &gt;Thane&lt;/option&gt;&lt;option name='620015' id='620015' value='Trichy' &gt;Trichy&lt;/option&gt;&lt;option name='695001' id='695001' value='Trivandrum' &gt;Trivandrum&lt;/option&gt;&lt;option name='390001' id='390001' value='Vadodara' &gt;Vadodara&lt;/option&gt;&lt;option name='520001' id='520001' value='Vijayawada' &gt;Vijayawada&lt;/option&gt;&lt;option name='531001' id='531001' value='Vizag' &gt;Vizag&lt;/option&gt;&lt;/select&gt;
  &lt;input type='hidden' name='city' id='city' value='201301'/&gt;
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Category&lt;/div&gt;
      &lt;div style="float:left"&gt;
      &lt;select class="post_ad_field" style="width:165px" name='categorySelect' id='categorySelect'"  onchange="getSubcatValue(this.value);"&gt;
      &lt;option id='0' value='0'&gt;Select Category&lt;/option&gt;
      &lt;%  
      Set&lt;Map.Entry&lt;String,ArrayList&lt;CategorydetailObject&gt;&gt;&gt; set =hm.entrySet(); 
  
      for(Map.Entry&lt;String,ArrayList&lt;CategorydetailObject&gt;&gt; me: set)
      {
         String cat= me.getKey();
      %&gt;
  
      &lt;option name="&lt;%=cat %&gt;" id="&lt;%=cat %&gt;" value="&lt;%=cat %&gt;"&gt;  &lt;%=cat %&gt;&lt;/option&gt;
      &lt;% 
      }
  
      %&gt;       
       &lt;/select&gt;
      &lt;input type='hidden' name='categorySelect' id='categorySelect' value=''/&gt;
      &lt;/div&gt;
      &lt;div class="blank10"&gt;&lt;/div&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;SubCategory&lt;/div&gt;
      &lt;div style="float:left"&gt;
      &lt;select class="post_ad_field" style="width:165px" name='subCatSelect' id='subCatSelect' onchange="onchangeSubcat(this.value);"&gt;
      &lt;option id='0' value='0'&gt;Select SubCategory&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type='hidden' name='subCatSelect' id='subCatSelect' value=''/&gt;
  
      &lt;/div&gt;
      &lt;div class="blank10"&gt;&lt;/div&gt;
      &lt;/TD&gt;
  &lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;DIV id=bb1&gt;&lt;div class="post_ad_fonts"&gt;Head Line&lt;/div&gt;
      &lt;div style="float:left"&gt;
    &lt;input style="width:440px" type="text" maxlength="64" name="headline" id="headline" class="post_ad_field"  value='' /&gt;  
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;DIV id=bb1&gt;&lt;div class="post_ad_fonts"&gt;Description&lt;/div&gt;
      &lt;div style="float:left;width :440px;"&gt;
    &lt;table border="0" style="margin:0px"&gt;&lt;tr&gt;&lt;td&gt;&lt;div id="showbar"&gt;Loading Html Editor...&lt;img src="images/ajax_loader.gif" alt="loading"/&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;textarea name="description" id="description " onfocus="if(this.value=='Adding more detail here will help you get more responses.')this.value='';" style="width:440px;height:170px"&gt;Adding more detail here will help you get more responses.&lt;/textarea&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  
  
      &lt;/TD&gt;
  &lt;/TR&gt;
  
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Mobile No.&lt;br/&gt;&lt;span style="font-weight:normal"&gt;(Optional)&lt;/span&gt;&lt;/div&gt;
  &lt;div style="float:left"&gt;
    &lt;input style="width:162px" type="text" maxlength="14" name="mobile" id="mobile" class="post_ad_field" value="" /&gt;    
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  
      &lt;/TD&gt;
  &lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Price&lt;br/&gt;&lt;span style="font-weight:normal"&gt;(Optional)&lt;/span&gt;&lt;/div&gt;
  &lt;div style="float:left"&gt;
    &lt;input style="width:162px" type="text" maxlength="14" name="price" id="price" class="post_ad_field" value="" /&gt;    
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  
      &lt;/TD&gt;
  &lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Owner type&lt;br/&gt;&lt;/div&gt;
  &lt;div style="float:left"&gt;
    &lt;select class="post_ad_field" style="width:165px" name='owner' id='owner'&gt;
  &lt;option id='0' name='0' value='0'&gt;Individual&lt;/option&gt;
  &lt;option name='22' id='22' value='Ahmedabad' &gt;Broker&lt;/option&gt;&lt;/select&gt;
  &lt;input type='hidden' name='ownertype' id='ownertype' value='Individual'/&gt;
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  &lt;/TD&gt;
  &lt;/TR&gt;
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Order type&lt;br/&gt;&lt;/div&gt;
  &lt;div style="float:left"&gt;
  &lt;select class="post_ad_field" style="width:165px" name='order' id='order'"&gt;
  &lt;option id='0' name='0' value='Available'&gt;Available&lt;/option&gt;
  &lt;option name='22' id='22' value='Required' &gt;Required&lt;/option&gt;&lt;/select&gt;
  &lt;input type='hidden' name='ordertype' id='ordertype' value='Available'/&gt;
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  &lt;/TD&gt;
  &lt;/TR&gt;
  
  
  
  
  
  &lt;TR&gt;
      &lt;TD&gt;
      &lt;div class="post_ad_fonts"&gt;Upload Image&lt;br/&gt;&lt;/div&gt;
  &lt;div style="float:left" id="UploadImage"&gt;
  
    &lt;html:file property="image1"&gt;&lt;/html:file&gt; 
    &lt;html:file property="image2"&gt;&lt;/html:file&gt;
    &lt;html:file property="image3"&gt;&lt;/html:file&gt;
  &lt;input type="file" name="image4"&gt;  
  &lt;/div&gt;
  &lt;div class="blank10"&gt;&lt;/div&gt;
  
      &lt;/TD&gt;
  &lt;/TR&gt;
  &lt;tr&gt;&lt;td&gt;&lt;div class="post_ad_fonts"&gt;&lt;br/&gt;&lt;/div&gt;&lt;div style="float:middle"&gt;&lt;html:submit&gt;POST ORDER&lt;/html:submit&gt;&lt;/div&gt; &lt;/td&gt;&lt;/tr&gt;
  &lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/html:form&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=blank10&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
  
  
  &lt;div id="floatMenu"&gt;
    &lt;ul class="menu1"&gt;
      &lt;li&gt;&lt;a href="#" onclick="return ret_home();"&gt; Home &lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;ul class="menu2"&gt;
      &lt;li&gt;&lt;a href="#" onclick="return ret_aboutus();"&gt; About Us &lt;/a&gt;&lt;/li&gt;
      &lt;!--&lt;li&gt;&lt;a href="#" onclick="return false;"&gt;  &lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#" onclick="return false;"&gt; &lt;/a&gt;&lt;/li&gt;--&gt;
    &lt;/ul&gt;
    &lt;ul class="menu3"&gt;
      &lt;li&gt;&lt;a href="#" onclick="return ret_contactus();"&gt; Contact Us &lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>