Bottyz Posted January 24, 2010 Share Posted January 24, 2010 Hi all, just a quickie. I want to only run a validate fax function if a fax number is entered... but i cant get the validate fax function to run from within the if statement. It runs fine if i set it up without the if user_fax!= '' statement. but i want the fax field optional. if ($user_fax != '') { if (validate_fax($user_fax) ) { $errors.="ERROR: Please enter a valid Fax Number including extension if applicable.<br><br>"; } } what am i doing wrong? thanks Link to comment https://forums.phpfreaks.com/topic/189634-syntax-problem/ Share on other sites More sharing options...
jl5501 Posted January 24, 2010 Share Posted January 24, 2010 try if(isset($user_fax)) { if(valid..........) { ..... } } Link to comment https://forums.phpfreaks.com/topic/189634-syntax-problem/#findComment-1000831 Share on other sites More sharing options...
Bottyz Posted January 24, 2010 Author Share Posted January 24, 2010 Thanks Jl5501, slightly different issue now EDIT... think it is now something to do with my validate function: function validate_fax($fax) { return preg_match('/^([0-9,+() ]{9,})+$/i', $fax); } Is my syntax correct for allowing only digits, brackets, plus symbol and spaces 9 characters minimum in length? Link to comment https://forums.phpfreaks.com/topic/189634-syntax-problem/#findComment-1000839 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.