I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter 1-15-2008
instead of 01-15-2008) ?
Something like this:
http://www.phpguru.org/date_preg/
?php
// Get this from where ever (format MM-DD-)
echo
i think this ties into the thread tedd started a week or so ago
about the best approach for collecting user data.
it would be much easier to validate if there were 3 text input fields
to collect the data, rather than 1, free-form field.
-nathan
On 15/01/2008, Adam Williams [EMAIL PROTECTED] wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter 1-15-2008
instead of 01-15-2008) ?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
On Jan 15, 2008 9:30 AM, Per Jessen [EMAIL PROTECTED] wrote:
Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
A regular expression perhaps?
you
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter 1-15-2008
instead of 01-15-2008) ?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
A regular expression perhaps?
/Per Jessen, Zürich
--
PHP General Mailing List (http://www.php.net/)
Nathan Nobbe wrote:
i think this ties into the thread tedd started a week or so ago
about the best approach for collecting user data.
it would be much easier to validate if there were 3 text input fields
to collect the data, rather than 1, free-form field.
I would stick to one date field
Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
explode() and checkdate() perhaps?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
On Jan 15, 2008 10:02 AM, Per Jessen [EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
i think this ties into the thread tedd started a week or so ago
about the best approach for collecting user data.
it would be much easier to validate if there were 3 text input fields
to collect the data,
On Tue, January 15, 2008 9:02 am, Per Jessen wrote:
Nathan Nobbe wrote:
i think this ties into the thread tedd started a week or so ago
about the best approach for collecting user data.
it would be much easier to validate if there were 3 text input
fields
to collect the data, rather than
On Jan 15, 2008 10:38 AM, Richard Lynch [EMAIL PROTECTED] wrote:
On Tue, January 15, 2008 9:02 am, Per Jessen wrote:
Nathan Nobbe wrote:
i think this ties into the thread tedd started a week or so ago
about the best approach for collecting user data.
it would be much easier to
Daniel Brown wrote:
By only doing JavaScript validation,
Just in case - I wasn't suggesting only doing javascript validation. I
think I said a simple javascript validation _followed_ (as in at
POST-time) by a semantic check. For which checkdate() seems pretty
optimal.
/Per Jessen,
clive wrote:
Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
explode() and checkdate() perhaps?
checkdate() sounds like just the thing.
/Per
On Jan 15, 2008 10:46 AM, Daniel Brown [EMAIL PROTECTED] wrote:
On Jan 15, 2008 10:38 AM, Richard Lynch [EMAIL PROTECTED] wrote:
On Tue, January 15, 2008 9:02 am, Per Jessen wrote:
Nathan Nobbe wrote:
i think this ties into the thread tedd started a week or so ago
about the
On Jan 15, 2008 9:27 AM, Adam Williams [EMAIL PROTECTED] wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter 1-15-2008
instead of 01-15-2008) ?
--
PHP General Mailing List (http://www.php.net/)
To
On Tue, January 15, 2008 8:27 am, Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter
1-15-2008
instead of 01-15-2008) ?
Making the user type the 0 is just plain rude. :-)
You could use a
Thanks, I think I have it:
$dateexplode = explode(-, $_POST[date_entered]);
if (!preg_match(/^(\d{2})$/, $dateexplode[0],$data1) ||
!preg_match(/^(\d{2})$/, $dateexplode[1],$data2) ||
!preg_match(/^(\d{4})$/, $dateexplode[2],$data3))
{
die (you have entered an invalid date);
On Jan 15, 2008 11:25 AM, Adam Williams [EMAIL PROTECTED] wrote:
Thanks, I think I have it:
$dateexplode = explode(-, $_POST[date_entered]);
if (!preg_match(/^(\d{2})$/, $dateexplode[0],$data1) ||
!preg_match(/^(\d{2})$/, $dateexplode[1],$data2) ||
!preg_match(/^(\d{4})$/,
Adam Williams wrote:
Thanks, I think I have it:
$dateexplode = explode(-, $_POST[date_entered]);
if (!preg_match(/^(\d{2})$/, $dateexplode[0],$data1) ||
!preg_match(/^(\d{2})$/, $dateexplode[1],$data2) ||
!preg_match(/^(\d{4})$/, $dateexplode[2],$data3))
{
die (you have
Andrew Ballard wrote:
Just curious why you won't take 1-15-2008. Once you validate it, you
can always assign it to a variable as either a timestamp or a DateTime
object and then format it however you want when you display it, send
it to a database, or whatever you are doing with the date.
On Jan 15, 2008 11:51 AM, Adam Williams [EMAIL PROTECTED] wrote:
Andrew Ballard wrote:
Just curious why you won't take 1-15-2008. Once you validate it, you
can always assign it to a variable as either a timestamp or a DateTime
object and then format it however you want when you display
On Jan 15, 2008 11:51 AM, Adam Williams [EMAIL PROTECTED] wrote:
Andrew Ballard wrote:
Just curious why you won't take 1-15-2008. Once you validate it, you
can always assign it to a variable as either a timestamp or a DateTime
object and then format it however you want when you display
Adam Williams wrote:
I'm having users enter dates in MM-DD- format. is there a way to
check if what they have entered is invalid (like if they enter 1-15-2008
instead of 01-15-2008) ?
$utime = strtotime($_POST['input']);
if ( $utime !== false
$_POST['input'] == date('m-d-Y',
On Jan 15, 2008 1:31 PM, Adam Williams [EMAIL PROTECTED] wrote:
Andrew Ballard wrote:
All the more reason I would turn it into a timestamp or DateTime
object in PHP first. That will prevent trying to insert something like
what I used above. Then I would get rid of the MySQL STR_TO_DATE
I'm having users enter dates in MM-DD- format. is there a way
to check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
Why not use something like http://www.dynarch.com/projects/calendar/
to make it easier for the users? Along with being
On Jan 15, 2008 1:31 PM, Adam Williams [EMAIL PROTECTED] wrote:
Andrew Ballard wrote:
All the more reason I would turn it into a timestamp or DateTime
object in PHP first. That will prevent trying to insert something like
what I used above. Then I would get rid of the MySQL STR_TO_DATE
Andrew Ballard wrote:
All the more reason I would turn it into a timestamp or DateTime
object in PHP first. That will prevent trying to insert something like
what I used above. Then I would get rid of the MySQL STR_TO_DATE
function in the $mysqli_insert_sql value just replace it with
something
On Jan 15, 2008 2:05 PM, Brady Mitchell [EMAIL PROTECTED] wrote:
I'm having users enter dates in MM-DD- format. is there a way
to check if what they have entered is invalid (like if they enter
1-15-2008 instead of 01-15-2008) ?
Why not use something like
On Jan 15, 2008 2:24 PM, Andrew Ballard [EMAIL PROTECTED] wrote:
On Jan 15, 2008 2:05 PM, Brady Mitchell [EMAIL PROTECTED] wrote:
I'm having users enter dates in MM-DD- format. is there a way
to check if what they have entered is invalid (like if they enter
1-15-2008 instead of
On Tue, January 15, 2008 12:31 pm, Adam Williams wrote:
Andrew Ballard wrote:
I don't see the point in needing to convert it to a timestamp. The
length_start and length_end fields in MySQL are defined as date
fields.
All I care about is the date, not the hours/minutes/seconds. If I
insert
On Jan 15, 2008 2:38 PM, Richard Lynch [EMAIL PROTECTED] wrote:
On Tue, January 15, 2008 12:31 pm, Adam Williams wrote:
Andrew Ballard wrote:
I don't see the point in needing to convert it to a timestamp. The
length_start and length_end fields in MySQL are defined as date
fields.
All I
31 matches
Mail list logo