<?php
if (count($errors) > 0):
?>
  <div class="error">
  	<?php foreach ($errors as $error) : ?>
  		<script type="text/javascript">
  			function error($error)
  			{
  				<?php echo '<script>alert("$error");</script>' ?>
  			}
  		</script>
  		<label><?php echo $error; ?></label>
  	<?php
  	endforeach
  	?>
  </div>
<?php
endif
?>