Drukowana wersja tematu

Kliknij tu, aby zobaczyć temat w orginalnym formacie

Forum PHP.pl _ HTML \ XHTML _ Wysyłanie formularza

Napisany przez: DNMX 13.12.2022, 16:11:44

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. <http://december.com/html/4/element/form.html action="" data-ajax="true" method="post">
  2. <http://december.com/html/4/element/input.html type="text" name="Login" maxlength="50" autocomplete="off" id="Login">
  3. <http://december.com/html/4/element/input.html type="password" value="" maxlength="26" class="size-200 x-field-1 input-password" id="Password"></http://december.com/html/4/element/input.html>
  4. <http://december.com/html/4/element/input.html type="hidden" id="step5" name="step5" value="OK"></http://december.com/html/4/element/input.html>
  5. <http://december.com/html/4/element/button.html 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';"><http://december.com/html/4/element/span.html class="ui-button-text">Wstecz</http://december.com/html/4/element/span.html></http://december.com/html/4/element/button.html>
  6. <http://december.com/html/4/element/button.html 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';"><http://december.com/html/4/element/span.html class="ui-button-text">Dalej</http://december.com/html/4/element/span.html></http://december.com/html/4/element/button.html>
  7. <http://december.com/html/4/element/input.html id="loginbutton" type="submit" style="display:none;" role="button" aria-disabled="false" onClick="document.getElementById('nextstepbutton').style.display = 'none';" value="Zaloguj"></http://december.com/html/4/element/input.html>
  8. </http://december.com/html/4/element/form.html>

Jak mogę go naprawić?

Napisany przez: nospor 13.12.2022, 16:16:07

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

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)