Tuesday, October 20, 2009

Infragistics WebDataGrid validation.

In our project we need to do validation for webdatagrid using javascript.

var Gkey,GIndex;
function EnterEditModeValidate(objGrid,Obj1Edited)
{
Gkey = Obj1Edited._cell._column._key;
GIndex = Obj1Edited.getCell().get_row()._index;
}
function ExitingEditValidate(sender,evntArgs)
{
//var index=sender.get_columns().get_columnFromKey(Gkey).get_index();
//var value=sender.get_rows().get_row(GIndex).get_cell(index).get_value();
var innT = document.getElementById("wdgProductList_ed0");
var iChars = "!@#$%^&*()+=-[]\\\;,./{}|\":<>?~_";
if(innT!=null)
{
var sValue = innT.children[0].value;
if(Gkey=="ShipAddress")
{
if(sValue=="")
{
alert("Please enter the value");
evntArgs.set_cancel(true);
}
if(sValue.length > 40)
{
alert("Charecters should be below 40");
evntArgs.set_cancel(true);
}
for (var count = 0; count <>
{
if (iChars.indexOf(sValue.charAt(count)) != -1)
{
alert ("Your string has special characters. \nThese are not allowed.");
evntArgs.set_cancel(true);
}
}
}
}
}