Search code examples
javascriptaemweb-componentsling

CQ/AEM where are functions like 'cq5forms_showMgs()' defined?


I noticed that CQ occasionally uses these javascript cq5forms functions and variables. I'm wondering where they are defined and how they work.

Specifically, I want to know where cq5forms_isEmpty() is defined. I'm trying to get the built in clientside validation to work, but the JavaScript console keeps giving a reference error that says cq5forms_isEmpty() is not defined.

Some other examples of these cq5forms function include the cq5forms_showMgs() function in clientvalidation.jsp for the built in password constraint:

...
if(last!=confirm) {
            cq5forms_showMsg(<%
                %>'<%= xssAPI.encodeForJSString(formId) %>',<%
                %>'<%= xssAPI.encodeForJSString(name) %>_confirm',<%
                %>'<%= xssAPI.encodeForJSString(ValidationHelper.getConstraintMessage(resource)) %>');
            return false; 
    }
...

And cq5forms_isArray() and cq5forms_regcheck() gets written out in FieldHelper.java:

    public static void writeClientRegexpText(...)
        ...
        out.write(id);
        out.write(";" +
                  "if ( cq5forms_isArray(obj)) { \n" +
                  "for(i=0;i<obj.length;i++) { \n" +
                  "if (!cq5forms_regcheck(obj[i].value, ");
        out.write(regexp);

        out.write(")) { \n" +"cq5forms_showMsg('");
        ...

If anyone could point me to where these are defined and how they are suppose to be used it would be much appreciated.


Solution

  • This javascript functions belong to the cq.forms clientlibrary. You can find the js code at the following location in crx /etc/clientlibs/foundation/form/form.js