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

302
Views
React Antd Input url validation

am validation the format of url and also am sending backed request if that url doesn't already taken, and if it is taken i make the validation to error if it is not taken i will make it success the problem is when i make it success event the url format is wrong it shows as it is success, i know i have to check if the format is correct and the api return true for the url not taking by other so how can i get the current status of the antd validation this is my code

     [![<Form.Item
              name="websiteUrl"
              className="max-w-sm"
              validateStatus={validationStatus}
              hasFeedback
              rules={\[
                {
                  required: true,
                  type: 'url',
                  message:
                    'Insert a Valid website URL (make sure to include http/https)',
                },
                // {
                //   pattern: new RegExp('^(ftp|http|https)://\[^ "\]+$'),
                // },
                ({ getFieldValue }) => ({
                  async validator(rule, value) {
                    if (value === '') {
                      return setValidationStatus('error');
                    } else {
                      setValidationStatus('validating');
                      await checkWebsiteUrlApi(String(value).trim())
                        .then((response) => {
                          if (response) {
                            setValidationStatus('error');
                            return Promise.reject(
                              new Error('URL already exits!')
                            );
                          } else {
                           
/* this is causing the problem before is set it to success i also have to check if the url is correct format before setting it to success */
setValidationStatus('success');
                            return Promise.resolve();
                          }
                        })
                        .catch((error) => {
                          setValidationStatus('error');
                          return Promise.reject(new Error(error?.message));
                        });
                    }
                  },
                }),
              \]}
            >
              <Input
                name="websiteUrl"
                defaultValue={websiteUrl}
                onChange={(e) => setWebsiteUrl(e.target.value)}
                className="max-w-sm"
              />
            </Form.Item>][1]][1]
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!