To enable validation you need to specify validation property|attribute for the input element
var formData = [ {type: "text", name: "UserName", value: "", label: "User Name", validate: "NotEmpty"} ]; var dhxForm = new dhtmlXForm("dhxFormObj", formData);
or
<input validate="NotEmpty" type="text">
With such markup, each time when you will try to save data, validation will fire. Also you can force form validation using:
dhxForm.validate();
When input fails validation it's marked with 'dhtmlx_validation_error' css class. So if you want to define custom styling you need to set those rule:
.dhtmlx_validation_error{ ... any custom marking rules here ... }
The custom messages can be added by using validation events.
There are four validation events:
There are 3 types of rules:
Standard rules are the next:
<input type="text" validate="ValidEmail" >
Custom rules can be created by defining custom function and using its name as validation rule.
<input type="text" validate="Greater100" >
function Greater100(data){ return (data>100); }
You can use a regural expression as value of validate attribute:
<input type="text" validate="[0-9]+" >