```
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

 <html>
 <head>
  <sx:head cache="true" />
<script>
   myfunction(a, b)
  {
      if ( a> b) 
      return true;
      else
      return false;   

  }
 </script>

</head>

```

....

```
 <s:form  action="saveXXXX"  >

  .... fields....                    

  <s:submit onclick="return myfunction(a, b);" />  //THIS ONE WORKS - NON AJAX
  <sx:submit onclick="return myfunction(a, b);" /> //Using sx ajax tag 
<sj:submit onclick="return myfunction(a, b);" id="formSubmit1" targets="formResult"  value="AJAX Submit" button="true" />  //if using Jquery Plugin ajax tag

 //how to stop form submittal if function returns false.    

  </s:form> 

```

The form works using s:submit .. but now that I'm trying to ajaxfy it with sx:submit ... or jquery's sj:submit ... 

I want to submit the form CONDITIONALLY using AJAX based on what the function returns.

How can it be done?