Re: combo box validation
| From: | Ashley Sheridan | Date: | Mon, 07 Jun 2010 17:57:12 +0000 |
| Subject: | Re: combo box validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305900@lists.php.net to get a copy of this message | ||
On Mon, 2010-06-07 at 13:49 -0400, David Mehler wrote:
> Hello,
> I've got a form with two combo boxes, one for the month one for the
> day. Both are required. I've got code that checks the post submission
> to ensure neither is empty. My problem is that if a user does not
> select anything in the combo boxes January first is sent, this i don't
> want. If they haven't selected anything i'd like that to show as an
> error.
> Thanks.
> Dave.
>
Make the first item in the select list something like this:
<option value="0" selected="selected">-- select month --</option>
Then just check for the 0 value in PHP when the form is submitted.
Thanks,
Ash
http://www.ashleysheridan.co.uk