Cjax Framework


Validation and Uploader Integration - Cjax 5.1+


This sample makes use of two different CJAX Plugins "validation" and "uploader" to create a full form-submission functionality. The validation plugin makes use of Jquery and Jquery.validate plugin, the uploader plugin is independent.
Validation plugin allows you to add unlimited validatation to your forms through the validate plugin, and the uploader plugin allows you to upload as many files as you like through ajax, the convination of these two plugins provide alot of flexibility such as pre-upload form submittion functionality (optionally the form can be submitted before the files are uploaded, then it can upload the files) and the post-form submittion which submits the form after the files have been uploaded, so there are three stages (pre, upload and post, the upload is automatic - while you control the pre and post). You may want to check out these two plugins invidiually to get a full idea how each one of them work.

This integration can be as simple as you want you or as sofisticated as you want!, since all settings are optional except the button_id and the upload directory!.

This integration allows you to do advanced functionality that can fit just about any project due to the flexiblity on both plugins. If you need to create directories before the the files are uploaded you may do so with the pre-post submition with the second validate parameter (specify a url). Then the post-form submition (url setting in the uploader) to save the form data, while both are optional. And the footprint is so small!.

Examples

PHP
<?php 

//5.1+

$rules = array(
    
'rules' => array(
        
'file1' => array(
            
'required' => true
        
),
        
'file2' => array(
            
'required' => true
        
),

    ),
    
'messages' => array(
        
'file1' => array(
            
'required' => 'Please select a file'
            
),
        
'file2' => array(
            
'required' => 'Please select a file'
            
)
        )
);


$ajax->validate('btnSubmit'null$rules)->uploader(
    array(
        
'target' => 'upload/directory/',
        
'url' => 'ajax.php?validation_uploader/post',
        
'success_message' => 'Form submitted successfully.'
        
)
    );

?>

Send form to server using ajax..

Submit Form

Send any form data through ajax...



Used in sample:

Previous Topic:  Previous Class    ·   Top of Page   ·   Demos Home   ·  

CodeIgniter  ·  Copyright © 2006 - 2012  ·  Cjax