Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][JavaScript]onsubmit nie działa
Forum PHP.pl > Forum > Przedszkole
Mgorka
Witam mam problem mianowicie formularz nie chce mi wywołać funkcji podaje kod
  1. <form id="formularz" name="formularz" action="data/engine/useraccount.php" method="post" onsubmit="return validateForm()">
  2. <div id="headreg2"><h2>Oswiadczenie:</h2></div>
  3.  
  4. <div class="bodyreg">
  5. <tr><td style="width: 200px;">Login</td><td style="width: 300px;"><input type="text" name="login" /></td><td style="width: 200px;">
  6. <div id="error0" class="noerror">Uzupełnij login</div></td></tr>
  7.  
  8. <tr><td style="width: 200px">Hasło</td><td style="width: 300px;"><input type="password" name="pass" /></td><td style="width: 200px;">
  9. <div id="error1" class="noerror">Uzupełnij hasło</div></td></tr>
  10.  
  11. <tr><td style="width: 200px">E-mail</td><td style="width: 300px;"><input type="text" name="email" /></td><td style="width: 200px;">
  12. <div id="error2" class="noerror">Wpisz email</div></td></tr>
  13.  
  14. <tr><td style="width: 200px">Status</td><td style="width: 300px;">Klient<input type="radio" name="status" value="1" />Sprzedawca<input type="radio" name="status" value="2"/></td><td style="width: 200px;">
  15. <div id="error3" class="noerror">Wybierz jedną z opcji</div></td></tr>
  16.  
  17.  
  18.  
  19. <tr><td style="width: 200px">Oswiadczenie</td><td style="width: 500px;"><input type="checkbox" name="reg" value="1" /> Oswiadczam że zapoznałem się z <a href="">regulaminem</a> oraz wyrażasz zgodę na gromadzenie, przetwarzanie i wykorzystywanie przez Grupę Allegro moich danych, teraz i w przyszłości, zgodnie z polskim prawem, w szczególności Ustawą o ochronie danych osobowych. Masz prawo wglądu do Twoich danych oraz ich poprawienia lub usunięcia. </td><td style="width: 200px;">
  20.  
  21. <div id="error4" class="noerror">Potwierdz</div></td></tr>
  22.  
  23. <tr><td style="width: 200px">Przepisz słowo z obrazka:<br /> <input type="text" name="code" /></td><td style="width: 300px;">
  24. <img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage/securimage_show.php?sid=98d624d0ee2bfb05a1f3530a35ec279f" />
  25.  
  26. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
  27. <param name="allowScriptAccess" value="sameDomain" />
  28. <param name="allowFullScreen" value="false" />
  29. <param name="movie" value="securimage/securimage_play.swf?audio=securimage/securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
  30.  
  31. <param name="quality" value="high" />
  32.  
  33. <param name="bgcolor" value="#ffffff" />
  34.  
  35. <embed src="securimage/securimage_play.swf?audio=securimage/securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
  36. </object>
  37.  
  38. <br />
  39.  
  40. <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage/securimage_show.php?sid=' + Math.random(); return false"><img src="securimage/images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
  41. <div style="clear: both"></div>
  42.  
  43. </td>
  44.  
  45. <td style="width: 200px;"><div id="error5" class="noerror">Wpisz kod z obrazka</div></td></tr>
  46.  
  47. <input type="hidden" name="date" value="2011-08-04">
  48. <tr><td></td><td><input type="submit" value="Zarejestruj" name="action"/></td></tr>
  49. </form>

js plikz z funkcją
  1. function validateForm(){
  2. var login = document.forms[formularz].login.value;
  3. var pass = document.forms[formularz].pass.value;
  4. var email = document.forms[formularz].email.value;
  5. var code = document.forms[formularz].code.value;
  6.  
  7. var errors = 0;
  8.  
  9. if(login == ""){
  10. errors++;
  11. document.getElementById('error0').className = 'error';
  12. }else{
  13. document.getElementById('error0').className = 'noerror';
  14. }
  15. if(pass == ""){
  16. errors++;
  17. document.getElementById('error1').className = 'error';
  18. }else{
  19. document.getElementById('error1').className = 'noerror';
  20. }
  21. if(email == ""){
  22. errors++;
  23. document.getElementById('error2').className = 'error';
  24. }else{
  25. document.getElementById('error2').className = 'noerror';
  26. }
  27. if(!document.forms[formularz].status[0].checked && !document.forms[formularz].status[1].checked){
  28. errors++;
  29. document.getElementById('error3').className = 'error';
  30. }else{
  31. document.getElementById('error3').className = 'noerror';
  32. }
  33. if(!document.forms[formularz].reg.checked){
  34. errors++;
  35. document.getElementById('error4').className = 'error';
  36. }else{
  37. document.getElementById('error4').className = 'noerror';
  38. }
  39. if(code == ""){
  40. errors++;
  41. document.getElementById('error5').className = 'error';
  42. }else{
  43. document.getElementById('error5').className = 'noerror';
  44. }
  45.  
  46. if(errors != 0){
  47. return false;
  48. }else{
  49. alert('Good');
  50. return true;
  51. }
  52. }
peter13135
a czy coś w stylu
<a href="#" onclick="validateForm()">lalala</a>
wywołuje Ci tą funkcję ? (pytam, by wyeliminować możliwość, że sama funkcja jest "kiepska" )
na moje oko document.forms[formularz].login.value; - tutaj powinny być 2 apostrofy
Mgorka
tak to były apostrofy dzięki za pomoc
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.