We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Formmail "required" problem

chunter
chunter Posts: 2,023 Forumite
Part of the Furniture 1,000 Posts Combo Breaker
This may be a little niche, but...

I'm trying to get a little more extravagant with Matt's formmail, but I'm having problems with the "required" field, where you list mandatory fields in the form.

Works ok for simple type "text" but I can't get it to work for

<input type="hidden" name="required" value="cars">

Have you a car?*

<td><select name="cars" id="cars">
<option selected>choose</option>
<option value="1">Yes</option>
<option value="2">No</option>
</select></td>



This is currently accepting "choose" as ok, but I want to force the user to return a value, preferably "Yes/No", bit "1/2" would be fine.

What am I doing wrong?

Comments

  • marka87uk
    marka87uk Posts: 441 Forumite
    Part of the Furniture 100 Posts Combo Breaker
    Can you not set the 'choose' to a value of 0, then use an if statement in the php to check the value, and if it is 0, then return the user to the page?
  • Chippy_Minton
    Chippy_Minton Posts: 3,339 Forumite
    You'll have to remove the 'Choose' option because, to the FormMail script, that represents a non-blank value being passed and satisfies the 'required' option. Use this:

    <select name="cars" id="cars">
    <option></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
    </select>

    Have you looked at nms FormMail? It's an improved and direct replacement for Matt's FormMail. Even better and more flexible is TFMail. Both these scripts can be downloaded from http://nms-cgi.sourceforge.net/scripts.shtml.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.5K Banking & Borrowing
  • 253.7K Reduce Debt & Boost Income
  • 454.5K Spending & Discounts
  • 245.5K Work, Benefits & Business
  • 601.4K Mortgages, Homes & Bills
  • 177.6K Life & Family
  • 259.4K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.