<?
include_once 'cmc_js_form_validation.inc.php';
//***********************************************
// EXAMPLE OF HOW TO USE THE js_validation Class
//***********************************************
// validation type codes:
// ne = not empty (required field)
// nu = numerical charachers only.
// anu = alphanumerical characters only
// first build an array with the form fields name
// and there validation type.
// 'field_name' => 'validation_type'
$arr = array( 'test_ne' => 'ne',
'test_nu' => 'nu',
'test_anu' => 'anu');
$js = new js_validation();
$js->set_js_form("testform");// send the forms name
$js->set_js_array($arr); // pass in the array
echo $js->get_js_code(); // echo out the javascript
?>
<form name="testform" method="post" action="<?=$PHPSELF?>" onsubmit="return val_testform();">
<h1>js_validation Class - Example Form<h1>
Not Empty (ne):<input type="text" name="test_ne"><br>
Numerical (nu):<input type="text" name="test_nu"><br>
Alphnumerical (anu)<input type="text" name="test_anu"><br>
<input type="submit" name="submit" value="validate">
</form>
|