Estimado lukas4 la primera opción que me poner si me funciona me manda el alerta cuando no lleno los campo y no me borra la información, pero cuando ya lleno todos los campos y le doy guardar no me guarda nada en mi base de datos el código quedo así:
Código Javascript
:
Ver original<script>
function validar(){
if(document.getElementById("folio").value==""){
alert("por favor inserte el folio.");
* * * document.getElementById("folio").focus();
* * * return false;
}
if(document.getElementById("cve_med").value==""){
alert("por favor inserte clave de medicion.");
* * * document.getElementById("cve_med").focus();
* * * return false;
}
if(document.getElementById("id").value==""){
alert("por favor inserte el numero de identificación.");
* * * document.getElementById("id").focus();
* * * return false;
}
if(document.getElementById("folio_cer").value==""){
alert("por favor inserte el folio de certificado.");
* * * document.getElementById("folio_cer").focus();
* * * return false;
}
document.getElementById("formulario").submit();
}
</script>
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body onkeypress="return pulsar(event)" onLoad="document.formulario.FOLIO.focus()"> <form name="formulario" id="formulario" action="<?=$_SERVER['PHP_SELF']?>" method="post" >
<table width="850" border="1" align="center"> <input type="text" id="FOLIO" name="FOLIO" size="8" maxlength="8"/> <td><div align="center">*Clave Medicion
</div></td> <input type="text" id="CVE_MED" name="CVE_MED" size="2" maxlength="2"/> <input type="text" id="NOMBRE" name="NOMBRE"/> <input type="text" id="ID" name="ID" size="2" maxlength="2"/> <td><div align="center">*Folio de Certificado
</div></td> <input type="text" id="FOLIO_CER" name="FOLIO_CER" size="9" maxlength="9"/> <input type="button" name="Guardar" value="Guardar" onClick="validar()" /> <label><div align="center">los campos marcados con un * son obligatorios
</div></label>
no se en que estoy mal y por que no me guarda
no se si podrías checarlo y decirme en que estoy mal o cual es mi error
de antemano te doy las gracias