// JavaScript Document

function check_asthmaLetter(form)  {

  if (form.Given.value == "")   {
    alert("Please enter a value for the \"Given\" field.");
    form.Given.focus();
    return (false);
  }
  if (form.surname.value == "")   {
    alert("Please enter a value for the \"surname\" field.");
    form.surname.focus();
    return (false);
  }
  if (form.PatientUR.value == "") {
    alert("Please enter a value for the \"PatientUR\" field.");
    form.PatientUR.focus();
    return (false);
  }
  if (form.PatientUR.value.length < 6)   {
    alert("Please enter at least 6 characters in the \"PatientUR\" field.");
    form.PatientUR.focus();
    return (false);
  }
  if (form.PatientUR.value.length > 7)  {
    alert("Please enter at most 7 characters in the \"PatientUR\" field.");
    form.PatientUR.focus();
    return (false);
  }
  
  var checkOK = "0123456789-.";
  var checkStr = theForm.PatientUR.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"PatientUR\" field.");
    form.PatientUR.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"PatientUR\" field.");
    form.PatientUR.focus();
    return (false);
  }
  return (true);
}
