Hi,
So I was trying to put _javascript_ validation right into my form definition, but ran into some funkiness (at least from my perspective).

First of all I realized that putting the _javascript_ in a field doesn't "invalidate" the form:

Here's my form definition:
  <fd:validation>
    <fd:_javascript_>
      <fd:failmessage>failed on form</fd:failmessage>
      cocoon.log.debug("form returning false");
      return false;
    </fd:_javascript_>
  </fd:validation>
  <fd:widgets>
    <fd:field id="action">
      <fd:label>action</fd:label>
      <fd:datatype base="string"/>
      <fd:validation>
        <fd:_javascript_>
          cocoon.log.debug("widget returning false");
          return false;
        </fd:_javascript_>
      </fd:validation>
    </fd:field>

What's interesting is that both log messages are printed.  However, if I change the <fd:_javascript_> on the form to return true then widget.isValid() returns true even though my action field still returns false.  CForms online documentation for <fd:_javascript_> says to consult the examples in the source.  I only found one example and it is directly under the form (not the widget).

Question #1: This leads me to believe that maybe I can't put <fd:_javascript_> under the <fd:field><fd:validation> element?

Also, the <fd:failmessage> element was wishful thinking on my part which doesn't seem to do anything.  The xml of the form looks the same after the forms transformer whether I return true or false. 

Question #2: Using <fd:_javascript_> for validation, is there a way to get messages printed out at all let alone something useful like this

<fd:_javascript_>
  if (!someDAO.getOrders().size() > 0) {
    // send "must attach order" message
  } else if (!someOtherDAO.isValidCustomer()) {
    // send "must register first" message
...

Maybe I'm just pushing the limits of the _javascript_ validator... any ideas?
Thanks,
Ben

Reply via email to