S
S
SexyMonkey2016-02-08 20:41:03
JavaScript
SexyMonkey, 2016-02-08 20:41:03

How to properly organize step-by-step form validation?

There is a step-by-step form like this.

<form action="#">

        <section>
            <input type="text">
            <input type="text">
            <input type="text">
        </section>

        <section>
            <input type="text">
            <input type="text">
            <input type="text">
        </section>

        <section>
            <input type="text">
            <input type="text">
            <input type="text">
        </section>

        <a href="#">next</a>
        
        <button>Send</button>
        
    </form>


Only one section is always open. Those. clicking on "Next" changes the active section.
How to organize data validation not for the entire form immediately upon submission, but separately for each section when clicking on "Next"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2016-02-08
@entermix

By clicking the "Next" button, validate only the open section

D
Dark Hole, 2016-02-08
@abyrkov

Here is the algorithm: -
Get the current section(!!!)
- Check it - Validate it
- Open
the next one
- Block the initial section

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question