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 Quote 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 (edited) 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 } Edited November 30, 2012 by SocialCloud Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.