AnsweredAssumed Answered

Form fields validation

Question asked by darkredd on Jun 1, 2015
Latest reply on Jun 11, 2015 by tonyrivet
Hello all,

I am trying to implement a custom form field validation, I have followed two tutorial along side studying the alfresco wiki and its related documentation; however I have not been able to achieve my objective.

Here is my js code which I am sure the function works:

if(typeof Mynamespace == "undefined" || !Mynamespace )
   var Mynamespace = {};

Mynamespace.forms.validation.checkEmailValidity = function checkEmailValidity(field, args, event, form, silent, message)
   var valid = true;

   valid = YAHOO.lang.trim(field.value).length !== 0;
   var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
      valid = re.test(field.value);
   return valid;

I minified the script and place both the scripts in the "\webapps\share\components\form\" folder.
I have added the script to the form dependencies file "".

And my form config:

<field id="my:field">
  <!– validation-handler param: js function name –>
  <constraint type="MANDATORY" validation-handler="Mynamespace.forms.validation.checkEmailValidity" event="keyup"/>

I am still unable to validate my field, what have I missed?

Help much appreciated.