<%@page import="mantenimiento.MantenimientoClientes"%>
<%@page import="persistencia.Empresas"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="mantenimiento.MantenimientoEmpresas"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<html>
     <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
        <title>JSP Page</title>
        
        <script>
function validateForm()
{
    if(document.formulario.clienteid.value=="")
    {
      alert("clienteid no puede estar vacio");
      document.frm.clienteid.focus();
      
      return false;
    }
     if(document.formulario.password.value!=document.formulario.repitapassword.value)
    {
      alert("Password es diferente");
      document.frm.password.focus();
      
      return false;
    }
     if(document.formulario.nombre.value=="")
    {
      alert("nombre no puede estar vacio");
      document.frm.pwd.focus();
       
      return false;
    }
     if(document.formulario.apellido.value=="")
    {
      alert("apellido no puede estar vacio");
      document.frm.pwd.focus();
      return false;
    }
     if(document.formulario.area.value=="")
    {
      alert("area no puede estar vacio");
      document.frm.pwd.focus();
      return false;
    }
}
</script>
    </head>
    <body>
        <form  name="formulario" action="ClienteAgregado.jsp" method="POST" onSubmit="return validateForm()">
       
        <table >
            <thead>
                
            </thead>
            <tbody>
                <tr>
                    <td>ClienteId</td>
                    <td><input type="text" name="clienteid" value="" /></td>
                </tr>
                <tr>
                    <td>EmpresaId</td>
                    <td><select name="EmpresaId">
                               <%
                               
                               MantenimientoEmpresas  lista = new MantenimientoEmpresas();
                                List empresas = lista.ListaEmpresas();
                               %>
                            <%   
                              persistencia.Empresas empresa = null;
                               
                                Iterator  iterador = empresas.iterator();
                                 %>
          <% while (iterador.hasNext()){
              String opcion = iterador.next().toString();
    
    %>
            <option><% out.println(" "+ opcion); %></option> 
  
  
  
  <% }%>
             
                          
                               
             </select> </td>
                </tr>
                <tr>
                    <td>Password</td>
                    <td><input type="password" name="password" value="" /></td>
                </tr>
                <tr>
                    <td>Repita Password</td>
                    <td><input type="password" name="repitapassword" value="" /></td>
                </tr>
                <tr>
                    <td>Nombre</td>
                    <td><input type="text" name="nombre" value="" /></td>
                </tr>
                <tr>
                    <td>Apellidp</td>
                    <td><input type="text" name="apellido" value="" /></td>
                </tr>
                <tr>
                    <td>Telefono</td>
                    <td><input type="text" name="telefono" value="" /></td>
                </tr>
                <tr>
                    <td>Area</td>
                    <td><input type="text" name="area" value="" /></td>
                </tr>
                <tr>
                    <td>Nivel</td>
                    <td><select name="nivel">
                                <option >1</option>
                                <option >2</option>
                                <option>3</option>
                                <option>4</option>
                                <option>5</option>
                            </select> </td>
                </tr>
            </tbody>
        </table>
       <input type="submit" name="submit" value="Submit">
 </form>
    </body>
</html>

i am using javascript to validate but if i a leave clienteid in blank the message appears BUT the page still goes to the action="ClienteAgregado.jsp" is likes the jsp ignores the javascript i dont know why.

it doesn't ignore it, as you say yourself: it shows the message.
call your action from within your javascript, that 'll stop the action being called if your result was 'false'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.