<?php
include("livevalidationphp.class.php"); // the LiveValidationPHP scripts
include("rules.inc.php"); // hold the rules
$html="";
$frmTestLive=new LiveValidationMassValidatePHP("frmTestLive",$_POST);
$frmTestLive->addRules($formRules["frmTestLive"]);
$html=$frmTestLive->generateAll();
// check for a post action
$frmTestErrors=array();
if(isSet($_POST["action"]))
{
if($_POST["action"]=="send_test_form")
{
$frmTestErrors=$frmTestLive->validate();
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>LiveValidationPHP | Example 1</title>
<link href="livevalidation/livevalidation.css" rel="stylesheet" type="text/css" media="screen">
<script language="javascript" type="text/javascript" src="livevalidation/livevalidation.js"></script>
</head>
<body>
<h1>Example 1</h1>
<?php
if(count($frmTestErrors)>0)
{
print "<strong>You have errors:</strong>";
print "<pre>";
print_r($frmTestErrors);
print "</pre>";
}
?>
<form name='frmTestLive' id='frmTestLive' action='' method='post'>
<input type='hidden' name='action' value='send_test_form'>
I dare you to say "hello"<br>
<p>
<input type='text' id='test_hello' name='test_hello' value=''> <input type='submit' value='press me'>
</p>
</form>
<script>
<?php
print $html;
?>
</script>
</body>
</html>
|