Tema: Onsubmit
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/09/2011, 15:08
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Onsubmit

Así, anidá las otras funciones en la que valida

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>titulo</title>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. function a(){
  10. alert('funcion A');
  11. }
  12. function b(){
  13. alert('funcion b');
  14. }
  15. function validar(){
  16. a();
  17. b();
  18. var x=document.forms["form1"]["texto"].value;
  19. if (x==null || x==""){
  20.   alert("Debe completar el campo texto");
  21.   return false;
  22. }
  23. }
  24. //]]>
  25. </script>
  26. </head>
  27. <body>
  28. <div>
  29. <?php
  30. if(isset($_POST['procesar'])){
  31. echo "<p>" . $_POST['texto'] . "</p>"; 
  32. }else{
  33. ?>
  34. <form name="form1" id="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>" onsubmit="return validar();">
  35. <p>
  36. <input type="text" name="texto" value="" />
  37. <input type="submit" name="procesar" value="procesar" />
  38. </p>
  39. </form>
  40. <?php
  41. }
  42. ?>
  43. </div>
  44. </body>
  45. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.