ok gracias lukas4 ya funciona la validación y guarda perfectamente quedo así:
Código HTML:
Ver original<?PHP //primera Tabla
if(isset($_POST["Guardar"]))
{
$FOLIO = $_POST['FOLIO'] = trim($_POST['FOLIO']);
$CVE_MED = $_POST['CVE_MED'] = trim($_POST['CVE_MED']);
$NOMBRE = $_POST['NOMBRE'] = trim($_POST['NOMBRE']);
if (empty($ID)){$ID='NULL';}
$FOLIO_CER = $_POST['FOLIO_CER'] = trim($_POST['FOLIO_CER']);
// Paso 1: Recibimos el formulario:
$FOLIO = $_POST['FOLIO'] = trim($_POST['FOLIO']);
mysql_connect("localhost", "root", "******");
mysql_select_db("PRONTO");
mysql_query ("INSERT INTO
prueba (FOLIO, CVE_MED, NOMBRE, ID, FOLIO_CER, FECHA)
VALUES('$FOLIO', '$CVE_MED', '$NOMBRE', $ID, '$FOLIO_CER', NOW())", mysql_connect(localhost , root , ******));
}
?>
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();
}
<!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"> <script type="text/javascript"> function mostrarTab(obj) {
rolling=obj.scrollTop;
if(typeof obj.selectionStart == 'number') {
// Resto de navegadores
var start = obj.selectionStart;
var end = obj.selectionEnd;
obj.value = obj.value.substring(0, start)+"\t";
obj.value+= obj.value.substring(start, obj.value.length);
obj.focus();
obj.selectionStart = obj.selectionEnd= end + 2;
}
else if(document.selection) {
// Internet Explorer
obj.focus();
var range = document.selection.createRange();
if(range.parentElement() != obj) return false;
if (range.text != "") {
if(typeof range.text == 'string'){
document.selection.createRange().text ="\t"+range.text;
}
else obj.value += "\t";
}
else
obj.value += "\t";
}
obj.scrollTop=rolling;
}
function tabulador(form,field)
{
var next=0, found=false
var f=form
//if(event.keyCode!=13) return;
for(var i=0;i<f.length;i++) {
if(field.name==f.item(i).name){
next=i+1;
found=true
break;
}
}
//MODIFICACION A LA FUNCION && f.item(next).style.display!='none'
while(found){
if( f.item(next).disabled==false && f.item(next).type!='hidden' && f.item(next).style.display!='none'){
f.item(next).focus();
break;
}
else{
if(next<f.length-1)
next=next+1;
else
break;
}
}
}
<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" onSubmit="return validar()">
<table width="850" border="1" align="center"> <input type="text" id="FOLIO" name="FOLIO" size="8" maxlength="8" onkeyup = "this.value=this.value.toUpperCase();if (this.value.length == this.getAttribute('maxlength')){tabulador(this.form,this)}"/> <td><div align="center">*Clave Medicion
</div></td> <input type="text" id="CVE_MED" name="CVE_MED" size="2" maxlength="2" onkeyup = "this.value=this.value.toUpperCase();if (this.value.length == this.getAttribute('maxlength')){tabulador(this.form,this)}"/> <input type="text" id="NOMBRE" name="NOMBRE" onkeyup = "this.value=this.value.toUpperCase();if (this.value.length == this.getAttribute('maxlength')){tabulador(this.form,this)}"/> <input type="text" id="ID" name="ID" size="2" maxlength="2" onkeyup = "this.value=this.value.toUpperCase();if (this.value.length == this.getAttribute('maxlength')){tabulador(this.form,this)}"/> <td><div align="center">*Folio de Certificado
</div></td> <input type="text" id="FOLIO_CER" name="FOLIO_CER" size="9" maxlength="9" onkeyup = "this.value=this.value.toUpperCase();if (this.value.length == this.getAttribute('maxlength')){tabulador(this.form,this)}"/> <input type="submit" name="Guardar" value="Guardar" /> <label><div align="center">los campos marcados con un * son obligatorios
</div></label>
Muchas gracias por tu ayuda que tengas una buena tarde