Enter key on input field make the webpage redirect to prev step in Django wizard

35 Views Asked by At

I have django wizard contains 4 steps: the first step is account step where user enters the account information the second step is personal information, at this step I have some problem:

  1. when the user press enter on some input field ( like card num field) the webpage redirect the user to the previous step ( Account step ),
  2. the account page returned with all fields filled except passwords ( they are return empty)

I will show snapshot of the webpage the form, and I will provide the code:

  <form method="post" enctype="multipart/form-data"
                                              class="multiStep-form style-one simplePresentCart-two">
                                            <div class="row">
                                                {% csrf_token %}
                                                {{ wizard.management_form|crispy }}
                                                {% if wizard.form.forms %}
                                                    {{ wizard.form.management_form|crispy }}
                                                    {% for form in wizard.form.forms %}
                                                        {% crispy form %}
                                                    {% endfor %}
                                                {% else %}
                                                    {% crispy wizard.form %}
                                                {% endif %}
                                                <div class="multiStep-footer">
                                                    <div class="multiStep-footer-flex">
                                                        <div class="multiStep-footer-left">
                                                            {% if wizard.steps.prev %}
                                                                <button formnovalidate
                                                                        name="wizard_goto_step"
                                                                        type="submit"
                                                                        class="primry-btn-2 lg-btn"
                                                                        value="{{ wizard.steps.prev }}">{% translate "prev step" %}</button>

                                                            {% endif %}
                                                        </div>
                                                        {% if wizard.steps.current == wizard.steps.last %}
                                                            <div class="multiStep-footer-right">
                                                                <input type="submit" class="primry-btn-2 lg-btn"
                                                                       value="{% translate "Register" %}"/>
                                                            </div>
                                                        {% else %}
                                                            <div class="multiStep-footer-right">
                                                                <input type="submit" class="primry-btn-2 lg-btn"
                                                                       value="{% translate "Next" %}"/>
                                                            </div>
                                                        {% endif %}
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
  • I have tried remove type="submit" from the prev. button, but still the enter key on any field on step2 redirect to the 1st page.
  • my form submission works successfully, I mean prev. and next button works perfectly, just I have this issue on input fields
  • I have tried put code in jQuery that handle the enter key pressing and it worked, but it will affect all inputs, and I also have many input fields in this wizard, so I need to fix the source of the problem.
0

There are 0 best solutions below