Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    How about using an array instead of a large if statement? Commented Aug 27, 2009 at 23:56
  • Thanks Brisbe42, work like a charm. There have another option to validate the input only? such a $("input") Commented Aug 28, 2009 at 0:03
  • 3
    return validatePrice(document.form.price) && validatePrice(document.form.price2) && validatePrice(document.form.price3) && validatePrice(document.form.price4) && validatePrice(document.form.price5); Commented Aug 28, 2009 at 0:05
  • Yes, you would just do validatePrice(document.form.price.value.trim()) for each of those. This would, naturally, entail then removing the price.focus() in each if statement in validatePrice, to make it work correctly, and change the if statements to just be if (price === "") and if (price !== ""). Commented Aug 28, 2009 at 0:08