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
Posts: 2,023 Forumite
in Techie Stuff
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?
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?
0
Comments
-
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?0
-
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.0
This discussion has been closed.
Confirm your email address to Create Threads and Reply
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