Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of stuartc  >  CMC_form_validation  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: How to use the class
Class: CMC_form_validation
PHP to JavaScript form validation generator.
Author: By
Last change:
Date: 2002-10-24 16:01
Size: 1,123 bytes
 

Contents

Class file image Download
<?
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>