Pessoal!
Tenho um cadastro onde valido o campo Matrícula do Professor. Ocorre que dentro do IDE do Eclipse 3.2 e no IE 6.0 funciona. No FF 2.0 ele não funciona.
Parte do form que trata a Matrícula:
<tr>
<td align="right" class="txtDestaque">Matrícula: <span class="txtCampoObrigatorio">*</span> </td>
<td><input name="matricula" class="forms" type="text" size="15" maxlength="15" value="<%=matricula%>" onBlur="validarMatricula()"></td>
</tr>
Script que valida a matrícula:
function validarMatricula(){
if(window.ActiveXObject) //IE
req = new ActiveXObject("Microsoft.XMLHTTP");
else
if (window.XMLHttpRequest) // nao IE
req = new XMLHttpRequest();
req.open("GET","professor_action.jsp?matricula="+document.formProfessor.matricula.value+"&acao=validaMatricula"+"&id="+document.formProfessor.id.value,false); // síncrono
req.onreadystatechange = function(){
if(req.readyState==4){
if(req.status == 200){
if(req.responseText.indexOf("true") != -1) {
alert("Matrícula já utilizada");
document.formProfessor.matricula.value ="";
document.formProfessor.matricula.focus();
}
}
}
}
req.send(null);
}
JSP que é chamado:
if (acao.equals("validaMatricula")) {
Professor prof = professorDao.getProfessorMatricula(request.getParameter("matricula"));
if (prof != null && prof.getPfr_id()!= id) {
out.print("true");
}
}
Coloquei um Alert no SCRIPT mas ele nem chega a executar.
Grato.