Liferay use aui validator to validate input field of the form. Alloy script provide default validator but many times we need to create new type validator.
See below default liferay aui validator :
<aui:input name="firstName" type="text" maxlength="40">
<aui:validator name="required" />
<aui:validator name="alpha" />
</aui:input>
Now, You can create your own type aui validator as below :
<aui:input name="firstName" type="text">
<aui:validator name="myValidator" errorMessage="numbers-not-allowed">
function(val, fieldNode, ruleValue){
var matches = val.match(/\d+/g);
if(matches != null)
return false;
else
return true;
}
</aui:validator>
</aui:input>
0 Comment(s)