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

136
Views
Validate form selection option custom input base on product type EDIT

So I think my last question wasn't cleared. Currently I am doing form validation for my project. I have form input with main field of "sku", "name", and "price", with custom select options of product type which have three products(Book, dvd, furniture) each product type has an input area base on the product selected, for example:

[enter image description here][1]

I am able to validate name, price, sku, and select option for errors. I can also console.log product type base on the value selected. The only problem is, I can't stop the form to submit even if my select option have empty input field. I can validate the error of that field only when user type something that is not of corrected value but if user select the option and the field is blank, submit field still able to submit. How would I write a condition that stop submission when the selected input form is blank? Example: "If productType is book, and that book value weight is empty, throw error: weight is needed, else submit.

function for handle submission: This field validate if there's an error, main form is empty, and if option not selected.

 const handleSubmit = (event) => {
event.preventDefault();

if (
  Object.keys(errors).length === 0 &&
  Object.keys(formValues).length !== 0 &&
  select !== ""
)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try placing the 'required' straight after the "<select required"

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!