PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

At least one product quantity field filled in

  1. Chintaru
    Member

    Hi,

    I'm trying to create an order form, consisting of 137 products (it's a bakery's website). I added several dummy products in the form for testing purposes, but at least one product must have a quantity filled in. I can't make any single product required because not every customer would buy it. I just need to make sure people can't go to the next step without buying anything. Any ideas on how could I accomplish this? I guess I could try something with jQuery or something but I just want to know if there's any functionality like this built in already :)

    Thank you in advance.

    Posted 12 years ago on Thursday December 15, 2011 | Permalink
  2. Hi Chintaru,

    I can't think of a way to do this with default functionality. You could definitely accomplish this with jQuery. It would also be possible to validate the field using the gform_validation hook; however, this would require a page refresh before the validation would fail which isn't ideal.

    Let me know if you need some tips for a jQuery solution. :)

    Posted 12 years ago on Thursday December 15, 2011 | Permalink
  3. Chintaru
    Member

    Thanks for the quick reply, David :) I've been doing some jQuery and unfortunately it's a little more complicated than I expected. Then again, I'm not much of an expert quite yet ;) I've tried to count a non-empty quantity field and throw out an alert when not a single field has any content, but for some reason the selector only applies to the first field. So if I enter a value in the first field, it works, but when I enter a value in any other after that it doesn't. Also tried to put a change event on the totals element but I couldn't get that to work either.

    Bottomline: I'll gladly accept any push in the right direction :)

    Posted 12 years ago on Friday December 16, 2011 | Permalink
  4. Chintaru, can you post your code at pastebin.com or pastie.org and we'll take a look for obvious signs of trouble? Thanks

    Posted 12 years ago on Tuesday December 20, 2011 | Permalink

This topic has been resolved and has been closed to new replies.