Re: Function return

From: Date: Fri, 02 Nov 2007 15:34:24 +0000
Subject: Re: Function return
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-263983@lists.php.net to get a copy of this message
That is correct, the due_date field should only accept a valid date format, such as MM/DD/YYYY. To bypass the need for a validation check for this field I simply set the text field to disabled and supplied the user with a javascript popup calendar that upon selection populates the date in the format I want. :) On 11/2/07, Nathan Nobbe <quickshiftin@gmail.com> wrote: > > On 11/2/07, Dan Shirah <mrsquash2@gmail.com> wrote: > > > > Ah, okay. So I could probably simplfy it more by trimming it from the > > start like this?? > > > > $due_date = trim($_POST['due_date']); > > > > > that works; > i personally prefer to initialize a variable then only set it if the user input meets some > > conditions; its called white-box validation. > > $due_date = ''; > > if(isset($_POST['due_date'])) && !empty($POST['due_date'])) { > $due_date = trim($_POST['due_date']); > } > > > the more you know about what the contents of due_date are supposed to be, the > > stronger you can make the check; for instance here, it sounds like it should be a date > so you wouldnt allow, say 'somecrazySting', to pass the validation. > > -nathan > > >

« previous php.general (#263983) next »