snookian Posted November 30, 2012 Share Posted November 30, 2012 Hi guys, Im going insane with what im sure is a simple problem, I have a series of fields in a form. 2 of these fields however require on or both to be filled in, and if both are not then flag an error, but for the life of me I am having a coding blank and cant figure it out. This is what i have conjured up so far, but as i have said im getting writers block and about to go insane. if (!empty($field01) || !empty($field02)) { //??????????? } else { echo '<p class="error">Please enter at least one field</p>'; } Please any help would be greatly appreciated. Ian Link to comment https://forums.phpfreaks.com/topic/271392-validation-for-atleast-one-field-filled/ Share on other sites More sharing options...
MDCode Posted November 30, 2012 Share Posted November 30, 2012 If that method is not working (which it should), why not just use: if(empty($field01) && empty($field02)) { echo '<p class="error">Please enter at least one field</p>'; } else { // whatever } Link to comment https://forums.phpfreaks.com/topic/271392-validation-for-atleast-one-field-filled/#findComment-1396434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.