Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jquery] jak zrobic LUB
nieraczek
post
Post #1





Grupa: Zarejestrowani
Postów: 405
Pomógł: 6
Dołączył: 12.01.2007

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


Mam przykładowo:
  1. $(document).ready(function()
  2. {
  3. $('#sf_guard_user_username').blur(function()
  4. {
  5. if($('#sf_guard_user_username').val().length == 0)
  6. {
  7. $('#sf_guard_user_username').css('background-color', 'orange');
  8. $('#rejestracja1').html('Login musi zawierać minimum 5. znaków.');
  9. }
  10. }
  11. });


Czyli, że po wyjściu z inputa jak nic w nim nie wpisano to wyświetla błąd, a jak zrobić żeby było: jeśli nastąpiło wyjście z inputa '#sf_guard_user_username' LUB naciśnięto button '#register':

bo tak nie działa:
  1. if($('#sf_guard_user_username').blur || $('#register').click)(function()


Czy zostaje tylko skopiowanie powyższego kodu i zamiana $('#sf_guard_user_username').blur(function() na $('#register').click(function() (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nieraczek
post
Post #2





Grupa: Zarejestrowani
Postów: 405
Pomógł: 6
Dołączył: 12.01.2007

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


Zrobiłem tak:

  1. <script type="text/javascript">
  2. $(document).ready(function()
  3. {
  4. $('#sf_guard_user_username').blur = twojaFunkcja();
  5.  
  6. $('#register').click = twojaFunkcja();
  7.  
  8.  
  9. function twojaFunkcja()
  10. {
  11. if($('#sf_guard_user_username').val().length == 0)
  12. {
  13. $('#sf_guard_user_username').css('background-color', 'orange');
  14. $('#rejestracja1').html('Login musi zawierać minimum 5. znaków.');
  15. }
  16. else
  17. {
  18. $('#sf_guard_user_username').css('background-color', null);
  19. $('#rejestracja1').html('');
  20. }
  21. }
  22.  
  23. });



Ale już na wstępie jak wejdę na stronę to mam to pole podświetlone jako błedne, nawet jak zakomentowalem: $('#sf_guard_user_username').blur = twojaFunkcja(); (dla pewności że jakimś cuden kursor sam nie wchodzi i wychodzi z tego pola (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) ) hm......... ?

Jak tą funkcję przeniosę nad $(document).ready(function() to i tak jest tak samo.

Ten post edytował nieraczek 12.03.2009, 17:54:08
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 8.10.2025 - 17:37