Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Submit zamiast alertu., kto sie kuma to bedzie 2 sekundy roboty
zaaap
post 2.01.2009, 13:12:10
Post #1





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 13.11.2008

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


Witam, postawilem umiescic live validation i mam prosbe o modyfikacje skryptu tak aby po spelnieniu warunkow nie wyskakiwal alert ale formularz zostal submitowany na odpowiednia strone. Nic sie nie kumam w JS niestety, prosze o pomoc.

  1. <form action="wysylanie.php" method="post">
  2. <legend>Example of form validation</legend>
  3. <p><label for="field1" class="displayBlock">Email (optional):</label><input id="field1" type="text"></p>
  4. <p><label for="field2" class="displayBlock">Acceptance (required):</label><input id="field2" class="checkbox LV_valid_field" type="checkbox"><span class="LV_validation_message LV_valid">Thankyou!</span></p>
  5. <p><label for="field3" class="displayBlock">Presence (required):</label><textarea id="field3" class="shallow" rows="2" cols="10"></textarea></p>
  6.  
  7. <p><input class="submit" value="Test me!" type="submit"></p>
  8. </form>
  9. <script type="text/javascript">
  10. var field1 = new LiveValidation( 'field1', {onlyOnSubmit: true } );
  11. field1.add( Validate.Email );
  12. var field2 = new LiveValidation( 'field2', {onlyOnSubmit: true } );
  13. field2.add( Validate.Acceptance );
  14. var field3 = new LiveValidation( 'field3', {onlyOnSubmit: true } );
  15. field3.add( Validate.Presence );
  16.  
  17. var automaticOnSubmit = field1.form.onsubmit;
  18. field1.form.onsubmit = function(){
  19. var valid = automaticOnSubmit();
  20. if(valid)alert('The form is valid!');
  21. return false;
  22. }
  23. </script>


Tzn podejrzewam ze modyfikacje trzeba gdzies tutaj zapodac: if(valid)alert('The form is valid!'); ale co konkretnie nie mam pojecia.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
l0ud
post 2.01.2009, 13:15:10
Post #2





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


Spróbuj usunąć te linie:
Kod
if(valid)alert('The form is valid!');
return false;


--------------------
XMPP: l0ud@chrome.pl
Go to the top of the page
+Quote Post
zaaap
post 2.01.2009, 13:19:18
Post #3





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 13.11.2008

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


Po usunieciu zawsze submituje forma, nawet jesli nie spelnia wymogów. A powinien jedynie jesli wszystko jest ok
Go to the top of the page
+Quote Post
bim2
post 2.01.2009, 13:22:22
Post #4





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


podmien na
  1. if(!valid)
  2. {
  3. alert('The form is not valid!');
  4. return false;
  5. }


--------------------
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 11:54