deathshadow - i'm not sure what your code above does, but I have done the following now: function form1($values=array()) { $nameclass="text"; if ($values['name'] == null) { $nameclass="error"; } // <input class="'.$nameclass.'" type="text" id="name" name="name" value="'.$_POST['name'].'" size="25"/> // } Code (markup): if ($_POST['process'] == 1) { if ($_POST['name'] == null || $_POST['company'] == null || $_POST['address1'] == null) { form1($_POST); } else { form2(('0')); } } Code (markup): This works fine and it assigns a different class attribue to the form input if the field is null. However, I am just repeating the code here and as I start validating more fields I will be repeating all the code - is there a better way of doing this? Can we pass variables to the function that lists the problematic fields? Ideally I want all the validation stuff done in the IF Statement at the bottom.