cancel
Showing results for 
Search instead for 
Did you mean: 

Field validation not working

monicag
Champ in-the-making
Champ in-the-making
Hi,

I try to add email validation to a field with validation handler. In share-form-config-custom.xml, added next lines:

<appearance>
  <field id="my:thirdPartyEmail">
        <constraint-handlers>
      <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.email" event="keyup" />
   </constraint-handlers>
  </field>
</appearance>


In browser in the create form, nothing happens, the field is saved without any validation. Is it something wrong or incomplete with the configuration? Using Alfresco Community 4.2.c.
3 REPLIES 3

darkredd
Star Contributor
Star Contributor

monicag
Champ in-the-making
Champ in-the-making
Hi,

Thank you for the reply. I tried the configuration and the js script from the posts and still the same result. The form is saved without any validation. Used debug in browser and the js validation function is never call. Looks like the constraint handler for the field is not read.

sofia
Champ in-the-making
Champ in-the-making
I think that there is no
 <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.email" event="keyup" /> 


You can verify it by yourelf in the file "form-config.xml" under "C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\"
You'll find different constraints regrouped into the balise <constraint-handlers> </constraint-handlers>

Instead of using this constraint, I advice you to use the validation used in the file "forms-runtime.js " , C:\Alfresco\tomcat\webapps\share\js\forms-runtime.js
You'll find there  Alfresco.forms.validation.email , an example of this validation is used in the page of user creation  C:\Alfresco\tomcat\webapps\share\components\console\users.js