Results 1 to 10 of 10

Thread: A drop down required field?

  1. #1
    Join Date
    Sep 2005
    Posts
    11

    Default A drop down required field?

    Hi all,

    I have created a form and have been asked to include a drop down field that asks the user how many delegates they would like to attend an event.

    The code I have used for the field is:

    <select name="Number of delegates" id="Number of delegates">
    <option value="Please Choose" selected="selected">Please Choose</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>

    I have also been asked if this field can be a required field. The user must choose between 1, 2 or 3. If they leave the default value of 'Please Choose' then it is flagged up in the error message.

    Is this possible and can anyone be kind enough to show me how this is done?

    Kind regards

  2. #2
    Join Date
    Jul 2005
    Posts
    175

    Default Re: A drop down required field?

    hi,

    yip, it's possible. try for example the following..


    <select name="nuode">
    <option value="default">Please Choose</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    ..in addition you have to add a hidden field to your form as below to get sure that the user has selected an option..


    <input type="hidden" name="conditions1" value=":##TEST#nuode !~ /default/#Number of delegates is missing.#" />
    i think this should work.

    best, Erik

  3. #3
    Join Date
    Sep 2005
    Posts
    11

    Default Re: A drop down required field?

    Thanks for the reply Erik.

    However, it doesn't seem to work. If I enter the option of 1, 2, 3 or even if I don't choose an option the form just redirects to the successful page.

    Choice 1, 2, 3 or default appears on the email regardless?

    Kind regards

  4. #4
    Join Date
    Jul 2005
    Posts
    175

    Default Re: A drop down required field?



    but it should work..
    i used it that way in conjunction with the choice of an explicit day of a month and it worked fine.
    i've no idea, the code should be correct i think..

    does your form work without the drop down field?
    maybe also try it with the drop down field but without the conditions..

    erik

  5. #5
    Join Date
    Sep 2005
    Posts
    11

    Default Re: A drop down required field?

    Is a strange one...

    Yes, the form does work, with or without the drop down.

    All of the fields work fine but the drop down field passes data to my email even if the user doesn't select an option and leaves it as default.

    ????

    Kind regards

  6. #6
    Join Date
    Jul 2005
    Posts
    175

    Default Re: A drop down required field?

    hm..

    at the time i cannot test on my server and i am not really a programmer..

    so i'll quackish tell you which configuration i've used:
    formmail version 7.04, fmbadhandler version 1.10, plain.txt template, bad_url and good and bad templates..

    hm.. and are you using a required hidden field in conjunction with a conditions hidden field in your form? maybe try only to use conditions without required, maybe that's the bug..

    otherwise i've no idea at the moment, or i fall over something..

    erik
    Last edited by asket; 09-Jan-2006 at 04:30 PM.

  7. #7
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: A drop down required field?

    Hi,

    If you don't need to use conditions for other things, just use required.

    Change the default value to empty:
    Code:
    <option value="" selected="selected">Please Choose</option>
    Then use required like this:
    Code:
    <input type="hidden" name="required" value="nuode" />
    Note that spaces in field names is not valid HTML.

    Use "nuode" or "Number_of_Delegates". No spaces!
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  8. #8
    Join Date
    Jul 2005
    Posts
    175

    Default Re: A drop down required field?

    the simplest is the best.. how stupid i am..

    ..but now i'm wondering if it would be possible to use required together with conditions in one and the same form without causing trouble?

  9. #9
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: A drop down required field?

    Hi,

    Yes, you can use both conditions and required.

    But, if you're using conditions, then it's best to not use required because required is checked before the conditions, and if there are any errors then the conditions don't get checked.

    All this means is that the error page will show the required failures, but not the conditions failures. When the user fixes the required failures, only then will they get to see the conditions failures.

    In short, it works, but it's less user-friendly.

    Conditions can do everything required can do (and more).
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  10. #10
    Join Date
    Jul 2005
    Posts
    175

    Default Re: A drop down required field?

    all clear. thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Javascript and formmail: drop down list
    By bwv in forum FormMail Subscription Support
    Replies: 4
    Last Post: 05-Nov-2004, 10:18 PM
  2. Required fields containing default text
    By tvulucy in forum FormMail Subscription Support
    Replies: 9
    Last Post: 08-Oct-2004, 09:26 PM
  3. Required Fields not working?
    By zoe77 in forum FormMail Subscription Support
    Replies: 2
    Last Post: 02-Jun-2004, 04:27 PM
  4. required field error
    By Ibis in forum FormMail Subscription Support
    Replies: 18
    Last Post: 02-Mar-2004, 09:04 AM
  5. required does not work ?!
    By flynst4r in forum FormMail Subscription Support
    Replies: 9
    Last Post: 26-Jan-2004, 09:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •