I can use empty($var) to identify if a field in a form has been left blank but how would you implement it so the form wouldn't be submited if there were blank fields within the form?
Printable View
I can use empty($var) to identify if a field in a form has been left blank but how would you implement it so the form wouldn't be submited if there were blank fields within the form?
wouldn't be submitted at all? you'd need to use JavaScript for that. you could check out a simple way of doing it using this tutorial from w3.
just in case you meant you just didn't want to do anything if any of your fields were empty, you could simply loop through your POST variable, checking if they're empty (using empty() if you'd like!), and if any are you could throw an error and just display the form again, or whatever.
thanks kows i'll have a look see
Sorted:)