<!--

// Client Side Javascript validation routines

// Display a confirmation dialog box before deletion	
function ConfirmDelete() {
  if (!confirm("Are you sure you wish to delete this record?")) {
    return false;
  }
  return true;
}

// Check a value has been entered for a mandatory text box control.
function ValidateRequiredField(pItem, pItemDescription) {
  if (pItem.value == "") { 
    alert(pItemDescription + ": This field is required");
    pItem.focus();
    return false;
  }
  return true;
}

// Check a value is a valid number
function ValidateNumeric(pItem, pItemDescription) {
  if (pItem.value != "") { 
    if (!(/(^[-+]?\d\d*\.\d*$)|(^[-+]?\d\d*$)|(^[-+]?\.\d\d*$)/.test(pItem.value))) {
      pItem.focus();
      alert(pItemDescription + ": This field must be numeric");
      return false;
    }
    return true;
  }
  return true;
}


// Check a value is a valid number
function ValidateLength(pItem, pItemDescription, pLength) {
  if (pItem.value != "") { 
    if (!(/(^[-+]?\d\d*\.\d*$)|(^[-+]?\d\d*$)|(^[-+]?\.\d\d*$)/.test(pItem.value))) {
      pItem.focus();
      alert(pItemDescription + ": This field must be numeric");
      return false;
    }
    return true;
  }
  return true;
}

// Check a value is a valid integer
function ValidateInteger(pItem, pItemDescription) {
  if (pItem.value != "") { 
    if (!(/(^[-+]?\d\d*$)/.test(pItem.value))) {
      pItem.focus();
      alert(pItemDescription + ": This field must be an integer");
      return false;
    }
    return true;
  }
  return true;
}


// Check that the length of a string is correct
function ValidateLength(pItem, pItemDescription, pLength) {
  var s;
  if (pItem.value != "") { 
    s = new String(pItem.value)
    if (s.length > pLength) {
      pItem.focus();
      alert(pItemDescription + ": This field must be no longer than " + pLength + " characters");
      return false;
    }
    return true;
  }
  return true;
}

//-->


