Solution to error when generating an alert with javascript? error: valida_estudiante is not defined at HTMLInputElement.onclick

0

function valida_estudiante(){
 if ( document.getElementById("idest").value==0 ) {
  alert("Digite el id del estudiante");
  document.getElementById("idest").focus();
  return false;
 }
 if ( document.getElementById("nombre").value==0 ) {
  alert("Digite el nombre del estudiante");
  document.getElementById("nombre").focus();
  return false;
 }
 document.form.submit();
}
 <script languaje="javascript" type="text/javascript" src="js/funciones.js"></script>
 </head>
 <body>
  <h1 align="center">Crear Estudiante</h1>
  <form name="form">
   <table align="center" width="400px" border="1px">
    <tr>
     <td colspan="2" align="center">Ingrese datos</td>
    </tr>
    <tr>
     <td>Identificacion:</td>
     <td><input type="text" name="idest" id="idest"/></td>
    </tr>
    <tr>
     <td>Nombre Completo:</td>
     <td><input type="text" name="nombre" id="nombre"/></td>
    </tr>
    <tr>
     <td>telefono:</td>
     <td><input type="text" name="tel" id="tel"></td>
    </tr>
    <tr>
     <td colspan="2" align="center"><input type="button" name="Aceptar" value="aceptar" onClick="valida_estudiante()"></td>
    </tr>
   </table>	
    
asked by andres_tam 11.05.2017 в 04:14
source

1 answer

0

You lack a key in the "validate_student" function

It is good practice to indentation your code so you can quickly identify these types of errors.

Try this corrected version

 function valida_estudiante(){ 
        if(document.getElementById("idest").value==0){ 
            alert("Digite el id del estudiante"); document.getElementById("idest").focus(); return false; 
        }
      }
    
answered by 11.05.2017 в 04:36