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

116
Views
I am able to move into next step in antd step form even though i have added validation in react.js

I am able to move into next step in antd step form even though i have added validation in react.js I have used default validation of antd form

 const steps = [
    {
      title: "Service Address",
      content: (
        <Form form={form}>
          <Card>
            <h1>Lead Information</h1>
                <Form.Item
                  rules={[{ required: true }]}
                  name={"first_name"}
                  label="First Name"
                >
                  <Input />
                </Form.Item>
                       </Card>
                          </Form>
     },
    {
      title: "Service Information",
      content: "Second-content",
    },

And this my map loop to return the steps

return (
    <>
      <Steps
        current={current}
      >
        {steps.map((item) => (
          <Step key={item.title} title={item.title} />
        ))}
      </Steps>
      <div className="steps-content">{steps[current].content}</div>
        {current < steps.length - 1 && (
              <Button type="primary" onClick={() => next()}>
                Next
              </Button>
        )}
 )
</>

Can some one please help me with This! Thanks in Advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like you are not doing it properly, validation only works if you submit a form, otherwise it doesn't trigger the validation.

You need to submit the form with the click of the Next button.

  const next = () => {
    setCurrent((prev) => prev + 1);
  };

  const onSubmit = (formValues) => {
    console.log(formValues)
    next();
  };
  const steps = [
    {
      title: "Service Address",
      content: (
        <Form form={form} onFinish={onSubmit}>
          <Card>
            <h1>Lead Information</h1>
            <Form.Item
              rules={[{ required: true }]}
              name={"first_name"}
              label="First Name"
            >
              <Input />
            </Form.Item>
          </Card>
        </Form>
      )
    },
    {
      title: "Service Information",
      content: "Second-content"
    }
  ];

  return (
    <div className="App">
      <Steps current={current}>
        {steps.map((item) => (
          <Steps.Step key={item.title} title={item.title} />
        ))}
      </Steps>
      <div className="steps-content">{steps[current].content}</div>
      {current < steps.length - 1 && (
        <Button type="primary" onClick={form.submit}>
          Next
        </Button>
      )}
    </div>
  );

You can see a working example here: https://codesandbox.io/s/upbeat-faraday-o16hj?file=/src/App.js

about 4 years ago · Juan Pablo Isaza Report
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!