Style a form after it's been submitted

A quick snippet from a recent project. The requirement was to be able to style a form after it was submitted to ensure all the validation messages were styled correctly. Using a bit of PHP it was easy to add a class to the form:

<?php
	$class = ''; 
	if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) { 
		$class = 'submitted'; 
	} 
?>
<form class="<?php echo $class ?>">

If you hate email but still want to keep in touch, follow me on Twitter.

Guy Routledge avatar
Currently available hire me