Live custom validation
"Column A" must not be empty
"Column B" must be a valid email
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Live custom validation</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<script>
var myGrid;
function doOnLoad(){
myGrid = new dhtmlXGridObject('gridbox');
myGrid.setImagePath('../../../codebase/imgs/');
myGrid.setHeader("Column A, Column B");
myGrid.setInitWidths("100,250");
myGrid.setColAlign("right,left");
myGrid.setColTypes("ed,ed");
myGrid.enableValidation(true,true);
myGrid.setColValidators("NotEmpty,ValidEmail");
myGrid.setColSorting("int,str");
myGrid.enableMultiselect(true);
myGrid.attachEvent("onLiveValidationError",function(id,ind,value){
document.getElementById('message').innerHTML="Error at cell ("+id+","+ind+"), value must "+(ind==0?"not be empty":"be a valid email");
return false;
});
myGrid.attachEvent("onLiveValidationCorrect",function(id,ind,value){
document.getElementById('message').innerHTML="";
return false;
});
myGrid.enableAutoWidth(true);
myGrid.enableAutoHeight(true);
myGrid.init();
myGrid.load("../common/grid.xml");
}
</script>
</head>
<body onload="doOnLoad();">
<div id="message" style="height:50px; font-weight:bold; color:red;"></div>
<div id="gridbox" style="width:350px;height:250px;background-color:white;overflow:hidden"></div>
<p>"Column A" must not be empty<br>"Column B" must be a valid email</p>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.