Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

556
Views
Nested native JavaScript form validation in React Bootstrap form

I have a React Bootstrap form which represents a customer sign up form for my website.

This Form contains two parts:

  1. The form group for field 1
  2. The SetOfNestedFields component, which also contains a list of form fields defined in the same way as field 1.

I have an onSubmit function which calls the native checkValidity() function on my Form.

This checkValidity() function only seems to evaluate Form with label Field1, it doesn't validate any of the Form fields in the SetOfNestedFields component.

Is there another function like checkValidity() which will check and validate not only the inputs in field1 (part 1 of form) but also all of the nested fields in the SetOfNestedFields component (part 2 of form)?

<Form validated={validated} onSubmit={handleSubmit}>
                   // Start Part 1 of form
                    <Form.Group controlId="field1">
                        <Form.Label>Field 1</Form.Label>
                        <Form.Control
                            required
                            type="text"
                            placeholder="Enter Field 1"
                            onChange={(e) => {
                                setField1(e.target.value);
                            }}
                        />
                    </Form.Group>
                   // End part 1 of form

                   // Start Part 2 of form
                    <FormGroup>
                        <SetOfNestedFields
                            onSubmit={handleSubmit}
                            isValidated={validated}
                        />
                    </FormGroup>
                   //End Part 2 of form

                    <Button type="submit">
                        Sign me up!
                    </Button>
                </Form>

I have an onSubmit function which checks form validity.

const handleSubmit = (event) => {
        if (form.checkValidity() === false) {
            event.stopPropagation();
            setValidated(true); 
        }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!