Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> walidacja formularza nt-y raz, Puste pole nie są jednak zawsze puste :(
DrJOB
post
Post #1





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

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


Witam,

sprawdzenie czy pole jest pouste poprzez:
Kod
if(pole == "" || pole == null){...}

nie działa jeśli w pole klepniemy spacje.
Co wtedy?

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gekon
post
Post #2





Grupa: Zarejestrowani
Postów: 614
Pomógł: 7
Dołączył: 10.11.2003
Skąd: Rzeszów/Kraków

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


  1. function trim(TheString)
  2. {
  3. var len;
  4.  
  5. len = TheString.length;
  6. while(TheString.substring(0,1) == " "){ //trim left
  7. TheString = TheString.substring(1, len);
  8. len = TheString.length;
  9. }
  10.  
  11. while(TheString.substring(len-1, len) == " "){ //trim right
  12. TheString = TheString.substring(0, len-1);
  13. len = TheString.length;
  14. }
  15. return TheString;
  16. }

  1. if(trim(pole) == "" || pole == null){...}
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: 24.12.2025 - 13:47