Login   Register  
PHP Classes
elePHPant
Icontem

File: example_w_jquery.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jonas Earendel  >  jForm Validator  >  example_w_jquery.php  >  Download  
File: example_w_jquery.php
Role: Example script
Content type: text/plain
Description: A small example with jQuery
Class: jForm Validator
Validate forms with rules defined in form template
Author: By
Last change: Added a link to the new css file.
Date: 1 year ago
Size: 1,709 bytes
 

Contents

Class file image Download
<?php

include_once('class.jForm.php');

$html '
    E-mail:<br />
    <input type="email" name="user[email]" required="required" value="john@doe.com#" /><br />

    Url:<br />
    <input type="url" name="user[url]" required="user[email]!=\'\'" value="#http://jform.lagerwall.net/" /><br />
'
;

//define('LANGUAGE','fr-FR');
//define('LANGUAGE','en-GB');
define('LANGUAGE','sv-SE');

$form = new jForm($html);

if(!empty(
$_POST) and $form -> validate($_POST))
{
    
$form->triggerError('The form has passed validation','email');
    
$form->triggerError('The form has passed validation','url');
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo LANGUAGE?>">
<head>
    <title>jForm php form validation demo!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="is.js"></script>
    <script type="text/javascript" src="jquery.validate.js"></script>
    <script type="text/javascript" src="jquery.validate.translations.<?php echo LANGUAGE?>.js"></script>
    <link rel="stylesheet" type="text/css" href="jform.css" media="screen, projection" />
    <style type="text/css">
        span.validator-status
        {
            background-image: url(?jform-validator-image);
        }
    </style>
    <script type="text/javascript">
        $(function() {
            $("form").validate();
        });
    </script>
</head>
<body>
<form id="jform" method="post" action="">
    <?php echo $form->html4(); ?>
    <input type="submit" />
</form>
</body>
</html>