To to validation checking or marking foelds mandatory while saving data, the below code can be used, here txtVendorName is the name of the control

function trim(strText) { while (strText.substring(0,1) == ‘ ‘) { strText = strText.substring(1, strText.length); } while (strText.substring(strText.length-1, strText.length) == ‘ ‘) { strText = strText.substring(0,strText.length-1); } return strText; }

function MandatoryCheck()
{
  var VendorName = document.getElementById(‘<%= txtVendorName.ClientID %>’); 
  if(trim(VendorName.value) == ”)
  {
      alert(“Please enter a Vendor name.”);
      return false;
  }
 }

Advertisements