validNum = new RegExp("[^0-9]")
validPrecio = new RegExp("[^0-9.]")
validHora = new RegExp("[^0-9:]")
validCodigo = new RegExp("[^a-zA-Z0-9_-]")
validCodigoa = new RegExp("[^\t\v\f\n\r a-zA-Z0-9._-]")

function CheckChar(Tipo){
  var x = event.keyCode
  
  if(Tipo=='Numero'){
    if(validNum.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Codigo'){
    if(validCodigo.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Codigoa'){
    if(validCodigoa.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Hora'){
    if(validHora.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }
  }else if(Tipo=='Precio'){
    if(validPrecio.test(String.fromCharCode(x))==true){
      event.returnValue=false
    }else{
      if(String.fromCharCode(x)==','){
        if(document.getElementById(window.event.srcElement.name).value.indexOf(',')!=-1){
          event.returnValue=false
        }
      }
    }
  }
}

function trim(cadena){ 
  for(i=0; i<cadena.length; ){
    if(cadena.charAt(i)==" ")
      cadena=cadena.substring(i+1, cadena.length);
    else
      break;
  }
  
  for(i=cadena.length-1; i>=0; i=cadena.length-1){
    if(cadena.charAt(i)==" ")
      cadena=cadena.substring(0,i);
    else
      break;
  }
  
  return cadena;
}

<!--
  var message = ""; 

   function clickIE(){ 
    if (document.all){ 
     (message); 
     return false; 
    } 
   } 

   function clickNS(e){ 
    if (document.layers || (document.getElementById && !document.all)){ 
     if (e.which == 2 || e.which == 3){ 
     (message); 
      return false; 
     } 
    } 
   } 

   if (document.layers){ 
    document.captureEvents(Event.MOUSEDOWN); 
    document.onmousedown = clickNS; 
   } else { 
    document.onmouseup = clickNS; 
    document.oncontextmenu = clickIE; 
   } 
   document.oncontextmenu = new Function("return false") 
//-->

function AbrirFecha(Campo){
  window.open("calendario.asp?Campo="+Campo+"&Formato=dd/mm/aaaa",'feature','width=231,height=221,resizeable=no,scrollbars=no')
}


function isDate(sDate) {
  var dArr = sDate.split("/");
  var d = new Date(dArr[1] + "/" + dArr[0] + "/" + dArr[2]);
  return d.getMonth() + 1 == dArr[1] && d.getDate() == dArr[0] && d.getFullYear() == dArr[2];
}

