Intersoft WebGrid Documentation
How-to: Validate that a selected column cannot be empty when adding a new row using OnRowValidate
See Also Send comments on this topic.

Glossary Item Box

WebGrid provides an OnRowValidate client side events.

In this topic, you will learn the basic thing on how to validate empty cell when adding new row using OnRowValidate.

To validate empty cell when adding new row using OnRowValidate

  1. Select WebGrid's instance and press F4.
  2. In Layout Settings, select ClientSideEvents, then set OnRowValidate to WebGrid1_OnRowValidate.
  3. Write the following function in OnRowValidate client side event:

    JavaScript Copy ImageCopy Code
    function WebGrid1_OnRowValidate(rowObject)
    {
      var cellName = wgGetCellByName(rowObject, "ContactName");
      if (cellName.cellValue == "" || typeof(cellName.cellValue) == "undefined") 
      {
        alert("You must fill in ContactName.");
            // set focus the cellProduct and activate edit mode.
            ISGetObject("WebGrid1").ActivateEditMode();
            // return false so that the addnew will not process.
            return false;
      }
      return true;
    }
    

  4. Run the project.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.