Los dos scripts no interactuan entre ellos por lo que no tendrian por que molestarse.... si funcionan por separado no tienen por que no hacerlo juntos...
Ahora bien comprobar1() diria que no esta bien.... he hecho unos cambios y así funciona, la parte ajax no la he mirado pero ...
y si quita lo que no vayas a usar... ni que sea por economia de red...
curiosa forma de diferenciar los campos obligatorios... con el nombre de la case.....
Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
function comprobar1(objform){
var mal=false;
numero=objform.elements.length;
for(a=0;a<numero;a++){
if (objform.elements[a].className=='obligatorio'){
if (objform.elements[a].value.length < 10){
objform.elements[a].style.backgroundColor="#FFD2DB";mal=true;
}else{
objform.elements[a].style.backgroundColor="white";
}
}
}
for(b=0;b < numero;b++){
if (objform.elements[b].className=='resultado'){
if (objform.elements[b].value.length < 2){
objform.elements[b].style.backgroundColor="#FFD2DB";mal=true;
}else{
objform.elements[b].style.backgroundColor="white";
}
}
}
if(mal){
alert("Por favor, complete los campos marcados.");
}else{
document.submit()
}
}
//--------------------------
// Verificar Bacuche
function nuevoAjax()
{
var xmlhttp=false;
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E) { xmlhttp=false; }
}
if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); }
return xmlhttp;
}
function eliminaEspacios(cadena)
{
var x=0, y=cadena.length-1;
while(cadena.charAt(x)==" ") x++;
while(cadena.charAt(y)==" ") y--;
return cadena.substr(x, y-x+1);
}
function validaIngreso(valora)
{
var reg=/(^[a-zA-Z0-9.@ ]{10,15}$)/;
if(reg.test(valora)) return true;
else return false;
}
function nuevoEvento(evento)
{
var divMensaje=document.getElementById("error");
if(evento=="ingreso")
{
var input=document.getElementById("ingreso");
var boton=document.getElementById("botonIngreso");
var valora=input.value;
var textoAccion="Ingresando...";
}
else
{
var input=document.getElementById("verificacion");
var boton=document.getElementById("botonVerificacion");
var valora=input.value;
var textoAccion="Comprobando...";
}
valora=eliminaEspacios(valora);
/*A <-- Y esto que hace aquí??? */
if(!validaIngreso(valora))
{
divMensaje.innerHTML="El bauche ingresado contiene caracteres o longitud inválida";
}
else
{
boton.disabled=true; input.disabled=true;
input.value=textoAccion;
var ajax=nuevoAjax();
ajax.open("POST", "comprobar.php", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(evento+"="+valora);
ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
input.value="";
boton.disabled=false; input.disabled=false;
divMensaje.innerHTML=ajax.responseText;
}
}
}
}
</script>
</head>
<body>
<form action="" method="get">
<input name="" type="text" class="obligatorio">
<input name="" type="text" class="resultado">
<input name="" type="button" onClick="comprobar1(this.form)">
</form>
</body>
</html>
Quim