Ver Mensaje Individual
  #10 (permalink)  
Antiguo 11/08/2009, 22:57
Avatar de tampon
tampon
 
Fecha de Ingreso: julio-2009
Mensajes: 420
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Expresiones regulares

Bien gracias por el dato, voy a buscar una tabla hexadecimal y partire de tu referencia, otra cosa mas el problema con el if anidado, intente esto:

Código js:
Ver original
  1. function nuevoAjax()
  2. {
  3.     var xmlhttp=false;
  4.     try
  5.     {
  6.         xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  7.     }
  8.     catch(e)
  9.     {
  10.         try
  11.         {
  12.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  13.         }
  14.         catch(E) { xmlhttp=false; }
  15.     }
  16.     if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); }
  17.  
  18.     return xmlhttp;
  19. }
  20.  
  21. function eliminaEspacios(cadena)
  22. {
  23.     var x=0, y=cadena.length-1;
  24.     while(cadena.charAt(x)==" ") x++;  
  25.     while(cadena.charAt(y)==" ") y--;  
  26.     return cadena.substr(x, y-x+1);
  27. }
  28.  
  29. function validaNombre(nombre)
  30. {
  31.     var reg=/(^[a-zA-Z]{15,45}$)/;
  32.     if(reg.test(nombre)) return true;
  33.     else return false;
  34. }
  35.  
  36. function validaMatricula(matricula)
  37. {
  38.     var reg=/(^[0-9a-zA-Z]{0,8}$)/;
  39.     if(reg.test(matricula)) return true;
  40.     else return false;
  41. }
  42.  
  43. function validaIngreso(valora)
  44. {
  45.     var reg=/(^[0-9]{10,18}$)/;
  46.     if(reg.test(valora)) return true;
  47.     else return false;
  48. }
  49.  
  50. function darValor(turno) {  
  51.     if (turno.checked==true){  
  52.         document.getElementById('turno').value=turno.value;
  53.     }
  54. }
  55.  
  56. function nuevoEvento(evento)
  57.        
  58. {
  59.     var divMensaje=document.getElementById("error");
  60.  
  61.     if(evento=="ingreso")
  62.     {
  63.         var matricula=document.getElementById("matricula").value;
  64.         var nombre=document.getElementById("nombre").value;
  65.         var colegio=document.getElementById("colegio").value;
  66.         var carrera=document.getElementById("TextBoxA").value;
  67.         var turno=document.getElementById("turno").value;
  68.         var concepto=document.getElementById("concepto").value;
  69.         var pago=document.getElementById("pago").value;
  70.         var input=document.getElementById("ingreso");
  71.         var boton=document.getElementById("botonIngreso");
  72.         var valora=input.value;
  73.         var textoAccion="Ingresando...";
  74.     }
  75.     else
  76.     {
  77.         var input=document.getElementById("verificacion");
  78.         var boton=document.getElementById("botonVerificacion");
  79.         var valora=input.value;
  80.         var textoAccion="Comprobando...";
  81.     }
  82.     if(!validaNombre(nombre)){
  83.         document.sumar1.nombre.style.backgroundColor="#FFD2DB";
  84.         alert("El nombre ingresado contiene caracteres o longitud invalida.");
  85.         boton.disabled=true; document.sumar1.okay1.checked = false;
  86.     }else {
  87.         document.sumar1.nombre.style.backgroundColor="#ffffff";
  88.        
  89.         if(!validaMatricula(matricula)){
  90.             document.sumar1.matricula.style.backgroundColor="#FFD2DB";
  91.             alert("La matricula ingresada contiene caracteres o longitud invalida.");
  92.             boton.disabled=true; document.sumar1.okay1.checked = false;
  93.         }else {
  94.             document.sumar1.matricula.style.backgroundColor="#ffffff";
  95.        
  96.             valora=eliminaEspacios(valora);
  97.             if(!validaIngreso(valora))
  98.             {
  99.                 document.sumar1.folio.style.backgroundColor="#FFD2DB";
  100.                 alert("El folio ingresado contiene caracteres o longitud invalida.");
  101.                 boton.disabled=true; document.sumar1.okay1.checked = false;
  102.             }else {
  103.                 document.sumar1.folio.style.backgroundColor="#ffffff";
  104.            
  105.                 if(document.sumar1.total1.value=='0'){
  106.                     document.sumar1.total1.style.backgroundColor="#FFD2DB";
  107.                     alert("La cantidad del deposito debe ser diferente a cero.");
  108.                     boton.disabled=true; document.sumar1.okay1.checked = false;
  109.                 }else {
  110.                     document.sumar1.total1.style.backgroundColor="#ffffff";
  111.                 }
  112.             }
  113.         }
  114.     }
  115.     else
  116.     {
  117.            
  118.         document.sumar1.disabled=true;
  119.         input.value=textoAccion;
  120.        
  121.         var ajax=nuevoAjax();
  122.         ajax.open("POST", "comprobar.php", true);
  123.         ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  124.         ajax.send(evento+"="+valora+"&matricula="+matricula+"&nombre="+nombre+"&colegio="+colegio+"&carrera="+carrera+"&nombre="+nombre+"&colegio="+colegio+"&carrera="+carrera+"&turno="+turno+"&concepto="+concepto+"&pago="+pago);
  125.        
  126.         ajax.onreadystatechange=function()
  127.         {
  128.             if (ajax.readyState==4)
  129.             {
  130.                 document.sumar1.reset();
  131.                 document.getElementById('TextBoxA').value = document.getElementById('ComboBox2').value;
  132.                 document.sumar1.disabled=false;
  133.                 boton.disabled=true; input.disabled=false;
  134.                 divMensaje.innerHTML=ajax.responseText;
  135.             }
  136.         }
  137.     }
  138. }

Pero lo empeore todo bueno almenos ya se que este si es un problema de sintaxis jaja.