function calls
Posted: Mon Jan 17, 2005 2:38 pm
Hi
I have a problem that I would appreciate some help on. I am calling a function that checks 3 things 1)If the textbox is empty, if its a valid date format and if its a valid date. The last two parts of the function work however the 1st part that checks if the text box has fields in it dosen't. The data entered is through a text box:
The function call is as:
the function is as follows:
I hope I explained this well enough, if anymore info is needed let me know
Thanks in advance
Twb
I have a problem that I would appreciate some help on. I am calling a function that checks 3 things 1)If the textbox is empty, if its a valid date format and if its a valid date. The last two parts of the function work however the 1st part that checks if the text box has fields in it dosen't. The data entered is through a text box:
The function call is as:
Code: Select all
<?php
if(!empty($_POSTї'txtSearch_from'])){
$error = ValidateText($_POSTї'txtSearch_from']);
if(!empty($error))
{ echo $error,'... For Search_From textbox'; }
}
?>Code: Select all
function ValidateText($date){
$msg = " ";
if(empty($date)){ echo 'test';
$msg .= (!empty($msg)) ? '<br>' : '';;
$msg .= 'Text box is empty';
return $msg;
echo'<br>';
exit();
}
if(!ereg('^(ї0-9]{2})/(ї0-9]{2})/(ї0-9]{4})$',$date,$parts)){
$msg .= (!empty($msg)) ? '<BR>': '';
$msg .= "Invalid birthdate format entry enter dd/mm/yyyy";
return $msg;
echo'<br>';
exit();
}
if(!checkdate ($partsї2],$partsї1],$partsї3])){
$msg = " ";
$msg .= (!empty($msg)) ? '<BR>': '';
$msg .= "The date of birth is invalid. Check that month is between 1-12
and day is valid for that month.";
return $msg;
echo '<br>';
exit();
}
}Thanks in advance
Twb