sofia403 Posted May 26, 2011 Share Posted May 26, 2011 Im curently using below code to check so that the date is entered (DATE1 required field) I also have another date form (DATE2) but its not required, however i want the user IF he starts entering DATE2 - fill out the whole date and not just partial (month or day or year) can someone sugest how i can do that? thank you. if( empty($_POST['year'])){ header("Location:Messages.php?msg=18"); exit(); } if( empty($_POST['day'])){ header("Location:Messages.php?msg=18"); exit(); } if( empty($_POST['month'])){ header("Location:Messages.php?msg=18"); exit(); } Link to comment https://forums.phpfreaks.com/topic/237557-help-with-date-validation/ Share on other sites More sharing options...
xyph Posted May 26, 2011 Share Posted May 26, 2011 Just need a complex if statement. Here's what you want if( empty($_POST['year']) || empty($_POST['month']) || empty($_POST['day']) ){ echo 'First date not entered'; exit(); } elseif( (!empty($_POST['year2']) || !empty($_POST['month2']) || !empty($_POST['day2'])) && (empty($_POST['year2']) || empty($_POST['month2']) || empty($_POST['day2'])) ) { echo 'Partial second date entered'; exit(); } echo 'Everything works out fine'; Link to comment https://forums.phpfreaks.com/topic/237557-help-with-date-validation/#findComment-1220718 Share on other sites More sharing options...
sofia403 Posted May 26, 2011 Author Share Posted May 26, 2011 thanks that solves my problem! Link to comment https://forums.phpfreaks.com/topic/237557-help-with-date-validation/#findComment-1220736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.