Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Długość tytułu
marcin0077
post
Post #1





Grupa: Zarejestrowani
Postów: 94
Pomógł: 0
Dołączył: 18.10.2008

Ostrzeżenie: (10%)
X----


Witam

Mam takie kod:

  1. if(subForm.elements["username"].value.length < 3 || subForm.elements["caption"].value.length < 2) {


i chciałbym zrobić żeby tytuł nie mógł być większy niż 30 znaków
zrobiłem coś takiego:

  1. if(subForm.elements["username"].value.length < 3 || subForm.elements["caption"].value.length < 2) || subForm.elements["caption"].value.length > 30){


ale lipa


pomoże ktoś?

Ten post edytował marcin0077 30.05.2010, 13:31:08
Go to the top of the page
+Quote Post
lobopol
post
Post #2





Grupa: Zarejestrowani
Postów: 1 729
Pomógł: 346
Dołączył: 4.04.2009

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


A nie możesz ograniczyć po prostu wielkości pola formularza a nie pakować w to js? <input type="text" maxlength="30">
Go to the top of the page
+Quote Post
croc
post
Post #3





Grupa: Zarejestrowani
Postów: 706
Pomógł: 108
Dołączył: 12.03.2010

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


Ja osobiście nie lubię maxlength w polach innych niż takie jak kod pocztowy czy pesel.

Kod ci nie działa, bo masz błąd z nawiasem. Mam nadzieję, że zdajesz sobie sprawę, że twój if sprawdza czy wystąpił błąd, a nie czy jest prawidłowo. Spróbuj tak:
[JAVASCRIPT] pobierz, plaintext
  1. if(subForm.elements["username"].value.length < 3 || subForm.elements["caption"].value.length < 2 || subForm.elements["caption"].value.length > 30) {
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post
marcin0077
post
Post #4





Grupa: Zarejestrowani
Postów: 94
Pomógł: 0
Dołączył: 18.10.2008

Ostrzeżenie: (10%)
X----


ok działa dzięki
Go to the top of the page
+Quote Post

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: 23.08.2025 - 07:57