Ask a Question related to PHP Development, Design and Development.
-
Jay Blanchard #1
RE: [PHP] Date Validation, Kinda'
[snip]
Now that I'm thinking about it, what is your goal with this? Is it to
make sure the date entered is within a certain range when compared to
another date? i.e. The date entered cannot be more than absolutevalue(10
days) away from the first date or is it just to make sure it's in the
proper format?
[/snip]
It is to make sure that the user has entered a valid future date in the
YYYYMMDD format into the form.
Jay Blanchard Guest
-
combo box date validation
Hi, As per our requirement, we need to put combo boxess for date input. we are giving the user to input as dd month year format from the given... -
Date Validation
I'm trying to find some Coldfusion code that will allow me to validate a date to make sure that it's in MM/DD/YY format and is actually a valid... -
Date Range Validation
Hello; CL_FRST (08/10/2004) and CL_LST (05/24/2005) holds the beginning and ending date of school calendar which is also prepopulated for every... -
Date Validation, Kinda'
Howdy, Has anyone written any date validation function or sequence. I have looked around, but haven't found anything. I am cobbling togather... -
date validation?
How to write an IsDate function that actually checks for a particular date format? Using try-catch on Convert.ToDateTime(sDate) doesn't catch... -
Jay Blanchard #2
RE: [PHP] Date Validation, Kinda'
[snip]
I'm thinking this:
1. you get the date from the user
2. validate it using checkdate()
3. get the current date
4. compare the two dates to see if the users date is later than todays
date
5. return true or return false
Sound good?
[/snip]
Sounds bueno! I am just tired, had checkdate() in hand...Thanks!
Jay Blanchard Guest
-
Ali #3
Re: [PHP] Date Validation, Kinda'
For future:
/*
Description: validateDate is self explantory
Usage: if($this->validateDate($dateofbirth) != false){ //valid } else { //failed validation }
*/
private function validateDate($dob){
$invalid = false;
$i = 0; //for D M Y
$date = explode("/", $dob);
foreach($date as $d){
if(!is_numeric($d)){ //String test
$invalid = true;
}
$i = $i+1;
}
if($invalid == false && $i == 3){ //Length(D M Y) and String test
if(checkdate($date[1],$date[0],$date[2])){ //Date test
return $dob;
} else {
return false;
}
} else {
return false;
}
}Ali Guest



Reply With Quote

