title: Calling two functions onsubmit of a form
body: <p>I am using client_side_validations gem in a rails application for form validation, it adds some functions for form on submit that does the validation, I need to perform a custom validation on my own that is outside of the functionality of the client_side_validations gem, so when I add it using <code>form.submit = function</code> it works, both validations are called. but it I don't understand how will the decision to either submit the form or not submit it will be made, if both functions return false then it should submit but it looks like even if one of them returns true the form is submitted without waiting for the other to return its value, How can I handle such a case, I cannot make it into one function because that will mean putting in my code inside the client_side_validations JavaScript file, which I would never want to do?</p>
  <p>Any ideas and help is appreciated.</p>
  <p>Here is my custom validation code for reference:</p>
  <pre><code> $('#new_business').submit -&gt;
      that = $('#business_referrer_code')
      if(that.attr(&quot;validated&quot;) == &quot;true&quot;)
        return true
      else
        code = $('#business_referrer_code')
        $.ajax '/representatives/validate_code',
          type: 'GET'
          dataType: 'json'
          data: &quot;code=#{code.val()}&quot;
          success: (data, textStatus, jqXHR) -&gt;
            if(data.error)
              that.after(&quot;&lt;label class='message'&gt; Invalid Reference Code&lt;/label&gt;&quot;)
            else
              that.attr(&quot;validated&quot;, true)
              that.submit()
        false
      true
  </code></pre>
  <p>The other code the is auto generated by client_side_validations is something I cannot change.</p>