Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js] [solved] 2 wyskakujace okna ?, dlaczego wyskakuja 2 okna zamiast jednego
Kemot1000
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 3.02.2007

Ostrzeżenie: (0%)
-----


To jest funkcja moze ktos mi powiedziec czemu wyskakuja 2 okna a nie jedno?? Gdzie jest blad?

  1. <script language="javascript" type="text/javascript">
  2.  
  3. function formValid1(){
  4. var rrr = document.getElementById('rrr');
  5.  
  6. if(isEmpty(rrr, "Please enter name"))
  7. {return false;}
  8. else{ if(isCapital(rrr, "Name needs to be in capitals"))
  9. {document.Form1.action = "http://anypage.com";
  10. document.Form1.target = "_blank";
  11. document.Form1.submit();
  12. return true;
  13. }
  14.  
  15. return false;
  16. }
  17. }
  18. function isEmpty(elem, helperMsg){
  19. if(elem.value.length == 0)
  20. {
  21. alert(helperMsg);
  22. elem.focus();
  23. return true;
  24. }
  25. return false;
  26. }
  27.  
  28. function isCapital(elem, helperMsg){
  29. var CapitalExp = /[A-Z]/;
  30. if(elem.value.match(CapitalExp)){
  31. return true;
  32. }else{
  33. alert(helperMsg);
  34. elem.focus();
  35. return false;
  36. }
  37. }
  38. </head>
  39. <form name=Form1 method="post"><input type="text" name=tekst1 id=rrr> <input type="submit" value="Button" name="Command" onClick= "return formValid1();" /></form>
  40.  
  41. </body>



ZNALAZLEM CO BYLO ZLE --- Temat mozna zamknac Ponizej rozwiazanie

  1. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  2. <title>Untitled Document</title>
  3.  
  4. <script language="javascript" type="text/javascript">
  5.  
  6. function formValid1()
  7. {
  8. var rrr = document.getElementById('rrr');
  9.  
  10. if(isEmpty(rrr, "Please enter name") || isCapital(rrr, "Name needs to be in capitals"))
  11. {
  12. return false;
  13. }
  14. else
  15. {
  16. document.Form1.action = "http://anypage.com";
  17. document.Form1.target = "_blank";
  18. document.Form1.submit();
  19. return false;
  20. }
  21.  
  22. }
  23.  
  24.  
  25. function isEmpty(elem, helperMsg){
  26. if(elem.value.length == 0)
  27. {
  28. alert(helperMsg);
  29. elem.focus();
  30. return true;
  31. }
  32. return false;
  33. }
  34.  
  35. function isCapital(elem, helperMsg){
  36. var CapitalExp = /[a-z]/;
  37. if(elem.value.match(CapitalExp)){
  38. alert(helperMsg);
  39. elem.focus();
  40. return true;
  41. }else{
  42.  
  43. return false;
  44. }
  45. }
  46. </head>
  47. <form name=Form1 method="post"><input type="text" name=tekst1 id=rrr> <input type="submit" value="Create User" name="Command" onClick= "java script: return formValid1(); return false" /></form>
  48.  
  49.  
  50.  
  51. </body>
  52. </html>


Ten post edytował Kemot1000 7.02.2007, 13:23:36
Go to the top of the page
+Quote Post

Posty w temacie
- Kemot1000   [js] [solved] 2 wyskakujace okna ?   7.02.2007, 12:23:42


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 20:11