3 Replies Latest reply on Jul 5, 2013 1:19 AM by riverouse

    Form-Global Constraints

    danchapmanme Level 1

      I want to validate a user sign-up form when the entire form is submitted. Un-like most of the OOB form components, I want my error message to show at the top of the form not at the position of the component. After some reading, I am thinking maybe using the Form-Global Constraints by setting the Validation Resource Type path (http://dev.day.com/docs/en/cq/current/developing/developing-forms.html).

       

      I have created a folder called validation in /apps/myApps/forms. I have created a JSP called servervalidation.jsp in the folder and  I have added the following code:

       

      <%@page session="false" %><%

      %><%@page import="java.text.SimpleDateFormat,

                      java.util.Date,

                      java.text.DateFormat,

                      java.text.ParsePosition,

                      com.day.cq.wcm.foundation.forms.FieldDescription,

                      com.day.cq.wcm.foundation.forms.FieldHelper,

                      com.day.cq.wcm.foundation.forms.ValidationInfo" %>

      <%

      %><%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%

      %><sling:defineObjects/>

      <%

          ValidationInfo.addConstraintError(slingRequest, "ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR"); 

          return;

      %>

       

      However, whenever I submit a form, no validation happens and the form just submits and redirects to the thank you page.

       

      What am I doing wrong?