Prev: Security Issue
Next: Test [don't read]
From: David Mehler on 7 Jun 2010 13:49 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.
From: Ashley Sheridan on 7 Jun 2010 13:57 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
From: Gerardo Benitez on 8 Jun 2010 11:57 Hi Dave, In general, you can validate this condition with javascript before to send the form, and if some errors exist, the form is not submitted. or validate the conditions in the server side with php. Gerardo. www.webseficientes.com.ar On Mon, Jun 7, 2010 at 2:49 PM, David Mehler <dave.mehler(a)gmail.com> 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. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
From: Ashley Sheridan on 8 Jun 2010 12:01 On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote: > Hi Dave, > > In general, you can validate this condition with javascript before to send > the form, and if some errors exist, the form is not submitted. > > or validate the conditions in the server side with php. > > Gerardo. > www.webseficientes.com.ar > > > On Mon, Jun 7, 2010 at 2:49 PM, David Mehler <dave.mehler(a)gmail.com> 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. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > You should change that to 'and' instead of an 'or'. Javascript validation is nice, but you should always validate everything on the server too. Thanks, Ash http://www.ashleysheridan.co.uk
From: Gerardo Benitez on 8 Jun 2010 12:07
your advice is welcome! Gerardo www.webseficientes.com.ar On Tue, Jun 8, 2010 at 1:01 PM, Ashley Sheridan <ash(a)ashleysheridan.co.uk>wrote: > On Tue, 2010-06-08 at 12:57 -0300, Gerardo Benitez wrote: > > Hi Dave, > > In general, you can validate this condition with javascript before to send > the form, and if some errors exist, the form is not submitted. > > or validate the conditions in the server side with php. > > Gerardo.www.webseficientes.com.ar > > > On Mon, Jun 7, 2010 at 2:49 PM, David Mehler <dave.mehler(a)gmail.com> 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. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > You should change that to 'and' instead of an 'or'. Javascript validation > is nice, but you should always validate everything on the server too. > > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > -- Gerardo Benitez |