Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wysyłanie formularza
DNMX
post 13.12.2022, 16:11:44
Post #1





Grupa: Zarejestrowani
Postów: 127
Pomógł: 0
Dołączył: 18.09.2021

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


Hej
Mam sobie formularz do logowania się na strone. Dwa inputy: login i hasło. Chcę, zeby działał na takiej zasadzie:

1. Wypełniasz login klikasz Dalej
2. Pojawia się input z hasłem. Login znika. Pojawia się przycisk "Zaloguj" i "Wróć".

Tyle o ile udało mi się to zakodować, żeby działało poprawnie w wersji mobilnej i "klikanej" na PC to mam problem, bo jak na PC jesteś w polu "login" i nacisniesz enter powoduje to wysłanie nieuzupełnionego formularza zamiast pojawienia się pola "Hasło". Kod wygląda tak:
  1. <form action="" data-ajax="true" method="post">
  2. <input type="text" name="Login" maxlength="50" autocomplete="off" id="Login">
  3. <input type="password" value="" maxlength="26" class="size-200 x-field-1 input-password" id="Password"></input>
  4. <input type="hidden" id="step5" name="step5" value="OK"></input>
  5. <button type="button" id="backbutton" style="display:none;" role="button" aria-disabled="false" onClick="document.getElementById('loginbutton').style.display = 'none';document.getElementById('PasswordLI').style.display = 'none';document.getElementById('LoginLI').style.display = 'block';document.getElementById('nextstepbutton').style.display = 'inline';document.getElementById('backbutton').style.display = 'none';"><span class="ui-button-text">Wstecz</span></button>
  6. <button type="button" id="nextstepbutton" aria-disabled="false" onClick="document.getElementById('loginbutton').style.display = 'inline';document.getElementById('PasswordLI').style.display = 'block';document.getElementById('LoginLI').style.display = 'none';document.getElementById('nextstepbutton').style.display = 'none';document.getElementById('backbutton').style.display = 'inline';"><span class="ui-button-text">Dalej</span></button>
  7. <input id="loginbutton" type="submit" style="display:none;" role="button" aria-disabled="false" onClick="document.getElementById('nextstepbutton').style.display = 'none';" value="Zaloguj"></input>
  8. </form>

Jak mogę go naprawić?
Go to the top of the page
+Quote Post
nospor
post 13.12.2022, 16:16:07
Post #2





Grupa: Moderatorzy
Postów: 36 457
Pomógł: 6297
Dołączył: 27.12.2004




Po pierwsze rozpisz to na funkcje i do inputow wkladaj wywolanie funkcji a nie zajebisci dlugi JS bo raz ze sie tego ni da czytac a dwa sam sie wkoncu pogubisz

Po drugie, dodaj zdarzenie onkeyup dla inputow i jak ktos kliknie enter to rob co maszrobic i daj return false w ten sposob formularz sie niewysle


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 27.04.2024 - 21:46