cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobia <>
Subject Re: Cforms and Ajax validation workaround?
Date Thu, 15 Feb 2007 16:10:53 GMT
Gary Larsen wrote:
> I need to use tab styling with groups since there are so many widgets
> on the form.  The issue is that when a use submits the form, a
> validation error could occur on a non-active tab.  To the user the
> submit button is just not working.
> Has anyone been able to come up with a solution to work around this
> issue?

I'm not sure if it's applicable to Ajax, but following our internal
usability guidelines we implemented this:

<xsl:template match="fi:form-template">
  <xsl:if test=".//fi:validation-message">
    <script type="text/javascript">
      <xsl:text>alert('The following data is missing or incorrect:\n</xsl:text>
      <xsl:for-each select=".//fi:validation-message">
        <xsl:value-of select="local:capitalize(../@id)"/>
        <xsl:if test="text()">
          <xsl:text> (</xsl:text>
          <xsl:value-of select="local:addslashes(normalize-space(.))"/>

It generates a javascript popup that informs the user about the fields
that need attention.  Here are the helper functions:

<func:function name="local:capitalize">
  <xsl:param name="s"/>
  <func:result select="concat(translate(substring($s, 1, 1), 
                              substring($s, 2))"/>

<func:function name="local:addslashes">
  <xsl:param name="s"/>
    <xsl:when test='contains($s, "&apos;")'>
      <func:result select='concat(substring-before($s, "&apos;"), 
                                  local:addslashes(substring-after($s, "&apos;")))'/>
      <func:result select="$s"/>



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message