03-01-2012 08:27 AM
<config>
<forms>
<dependencies>
<js src="/custom-form-validation.js" />
</dependencies>
</forms>
</config>
and connect to my field<field id="mcwm:shortProjectNumber" set="general" mandatory="true">
<constraint-handlers>
<constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.checkNumber" event="keyup" />
</constraint-handlers>
</field>
Alfresco.forms.validation.checkNumber = function checkNumber(field, args, event, form, silent, message) {
var ok = (field.value=="") || field.value.match("^\\d{4}\\/\\d{4}$");
var valid = ok != null && ok;
if (!valid) {
YAHOO.util.Dom.setStyle(field.id, "border", "2px solid red");
}
else {
YAHOO.util.Dom.setStyle(field.id, "border", "");
}
// Inform the user if invalid
if (!valid && !silent && form)
{
var msg = "The number must match the pattern 1234/5678.";
form.addError(form.getFieldLabel(field.id) + " " + msg, field);
}
return valid;
};
01-20-2015 01:41 AM
08-24-2015 07:43 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.