DHTMLX Docs & Samples Explorer

Live Validation

Source
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxform_dhx_skyblue.css">
    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxform.js"></script>
    <script>
var myForm,
formData;
function doOnLoad() {
    formData = [{
        type: "settings",
        position: "label-left",
        labelWidth: 130,
        inputWidth: 160
    }, {
        type: "label",
        label: "New project"
    }, {
        type: "input",
        label: "Project Name",
        value: "",
        validate: "NotEmpty"
    }, {
        type: "input",
        label: "Project Description",
        value: "",
        validate: "NotEmpty"
    }, {
        type: "input",
        label: "E-mail",
        value: "",
        validate: "NotEmpty,ValidEmail"
    }, {
        type: "select",
        label: "User Type",
        validate: "myFunc",
        options: [{
            value: 0,
            text: ""
        }, {
            value: 1,
            text: "User"
        }, {
            value: 2,
            text: "Power User"
        }, {
            value: 3,
            text: "Mega User"
        }, {
            value: 4,
            text: "Administrator"
        }]
        }, {
        type: "button",
        value: "Submit"
    }];
    myForm = new dhtmlXForm("myForm", formData);
    myForm.enableLiveValidation(true);
    myForm.attachEvent("onButtonClick", function() {
        myForm.validate();
    });
}
function myFunc(val) {
    return (val > 0);
}
</script> <div id="myForm" style="height:510px;"></div>