//validation routines without return values
function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
    }
    
    
function validate_setmsg(message, mode)
{
//mode: string: off,on,clear
var div=document.getElementById("diverrmsg");
if (div==null ||div ==false) return;
if (mode=="on" )
{
    document.getElementById("errmsg").innerHTML=document.getElementById("errmsg").innerHTML + message + "<br/>";
    div.style.display="block";
}
else
{ 
   if (mode=="clear") document.getElementById("errmsg").innerHTML="";

    div.style.display="none";
}
}
function validate_ishmn()
{

 var chk = document.getElementById("ishmni");
 if (chk!=null)
 {
    var sChk = chk.value.toUpperCase();
    var sVal = document.getElementById("ishmnv").value;
    if (sChk == sVal)
    {
    return true;
    }
    else
    {
    return false;
    }
 }
 else
 {
 return true;
 }
}
//validate functions return true if OK, false if validation fails
function validate_required(field)
{
    if (field==null || field=="" || field==false) return true;

    with (field)
    {
        if (value==null||value=="")
          {return false;}
        else {return true;}
    }
}
function validate_numeric(field, intonly)
{
    if (field==null || field=="" || field==false) return false;

    with (field)
    {
        if (value==null || value=="") return true;
        
        if (intonly==true)
        {
            return isInteger(value);
        }
        else

        {
            return isNumeric(value);
        }
    }
}
function validate_email(field)
{
    if (field==null || field=="" || field==false) return false;
        with (field)
            {
            if (value == null) return false;
            value = val_trim(value);
              if (!value.toString().match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)) return false;
            }
            return true;
} 
function validate_phone(field)
{
    if (field==null || field=="" || field==false) return false;
        with (field)
            {
              if (value == null || !value.toString().match(/^((\(\d{3}\)[ ]?)|(\d{3}[-]?))\d{3}[-]?\d{4}$/)) return false;
            }
            return true;
} 

function validate_zip(field)
{
    if (field==null || field=="" || field==false) return false;
        with (field)
            {
              if (value == null || !value.toString().match(/^(\d{5})|(\d{5}[-]\d{4})$/)) return false;
            }
            return true;
} 
function validate_date(field)
{
    if (field==null || field=="" || field==false) return false;
        with (field)
            {
            // /^(0?[1-9]|1[012])[- \.\/](0?[1-9]|[12][0-9]|3[01])[- \.\/](19|20)?\{2}$/
              if (value == null || !value.toString().match(/^\d{1,2}(\-|\/|\.)\d{1,2}(\-|\/|\.)\d{4}$/)) return false;
            }
            return true;
} 
 
function isInteger(value) {
  if (value == null || !value.toString().match(/^[-]?\d*$/)) return false;
  return true;
  }
function isNumeric(value) {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
  return true;
  }

function val_trim(strInput)
{
return strInput.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
