Location: PHPKode > projects > PHPCatalog > PHPCatalog/include/template/tmpl.js_modify.inc
<SCRIPT language="Javascript1.1">
<!--

function isDigit(string) {
    if (! string) return false;
    var Chars = "0123456789-.";

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}

function checkDecimals(string) {
    var Chars = ".";
    var count = 0;

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) != -1)
         ++count;
    }
    if(count > 1)
    	return false;
    else
    	return true;
}

function validate()
{
   if(document.modifyRecord.invCode.value == ""){
      alert("Please enter an inventory code.");
      document.modifyRecord.invCode.focus();
      return false;
   }
   if(document.modifyRecord.item.value == ""){
      alert("Please enter an item name.");
      document.modifyRecord.item.focus();
      return false;
   }
   if(document.modifyRecord.price.value == ""){
      alert("Please enter the price.");
      document.modifyRecord.price.focus();
      return false;
   }
   if(! isDigit(document.modifyRecord.price.value) ||
   			! checkDecimals(document.modifyRecord.price.value)) {
      alert("Product price must be a decimal number.");
      document.modifyRecord.price.focus();
      return false;
   }
	if(document.modifyRecord.price.value >= {maxPrice}) {
      alert("Product price must be less than ${maxPriceFormat}.");
      document.modifyRecord.price.focus();
      return false;
   }
   if(document.modifyRecord.category.value == "" &&
   		document.modifyRecord.selectCategory.value == "%") {
      alert("Please enter a category or select from the pull-down.");
      document.modifyRecord.category.focus();
      return false;
   }
   if(document.modifyRecord.description.value == ""){
      alert("Please enter a description.");
      document.modifyRecord.description.focus();
      return false;
   }
   return true;
}

-->
</SCRIPT>
Return current item: PHPCatalog