function clientside_validation($properties)
    {

        // default properties of the client-side validation
        $defaults = array(
            'clientside_disabled'       =>  false,
            'close_tips'                =>  true,
            'disable_upload_validation' =>  false,
            'on_ready'                  =>  false,
            'scroll_to_error'           =>  true,
            'tips_position'             =>  'left',
            'validate_on_the_fly'       =>  false,
            'validate_all'              =>  false,
        );

        // set the default properties for the client-side validation
        if (!isset($this->form_properties['clientside_validation'])) $this->form_properties['clientside_validation'] = $defaults;

        // if client-side validation needs to be disabled
        if ($properties == false) $this->form_properties['clientside_validation']['clientside_disabled'] = true;

        // if custom settings for client-side validation
        elseif (is_array($properties))

            // merge the new settings with the old ones
            $this->form_properties['clientside_validation'] = array_merge($this->form_properties['clientside_validation'], $properties);

    }
function clientside_validation($properties)
    {

        // default properties of the client-side validation
        $defaults = array(
            'clientside_disabled'       =>  false,
            'close_tips'                =>  true,
            'disable_upload_validation' =>  false,
            'on_ready'                  =>  false,
            'scroll_to_error'           =>  true,
            'tips_position'             =>  'left',
            'validate_on_the_fly'       =>  false,
            'validate_all'              =>  false,
        );

        // set the default properties for the client-side validation
        if (!isset($this->form_properties['clientside_validation'])) $this->form_properties['clientside_validation'] = $defaults;

        // if client-side validation needs to be disabled
        if ($properties == false) $this->form_properties['clientside_validation']['clientside_disabled'] = true;

        // if custom settings for client-side validation
        elseif (is_array($properties))

            // merge the new settings with the old ones
            $this->form_properties['clientside_validation'] = array_merge($this->form_properties['clientside_validation'], $properties);

    }
function clientside_validation ( $ properties ) { // default properties of the client-side validation $ defaults = array ( 'clientside_disabled' => false , 'close_tips' => true , 'disable_upload_validation' => false , 'on_ready' => false , 'scroll_to_error' => true , 'tips_position' => 'left' , 'validate_on_the_fly' => false , 'validate_all' => false , ) ; // set the default properties for the client-side validation if ( ! isset ( $ this -> form_properties [ 'clientside_validation' ] ) ) $ this -> form_properties [ 'clientside_validation' ] = $ defaults ; // if client-side validation needs to be disabled if ( $ properties == false ) $ this -> form_properties [ 'clientside_validation' ] [ 'clientside_disabled' ] = true ; // if custom settings for client-side validation elseif ( is_array ( $ properties ) ) // merge the new settings with the old ones $ this -> form_properties [ 'clientside_validation' ] = array_merge ( $ this -> form_properties [ 'clientside_validation' ] , $ properties ) ; }
Sets properties for the client-side validation.

Client-side validation, when enabled, occurs on the "onsubmit" event of the form.

<code>
//  create a new form
$form = new Zebra_Form('my_form');

// disable client-side validation
$form->clientside_validation(false);

// enable client-side validation using default properties
$form->clientside_validation(true);

// enable client-side validation using customized properties
$form->clientside_validation(array(
'close_tips'                =>  false,      //  don't show a "close" button on tips with error messages
'on_ready'                  =>  false,      //  no function to be executed when the form is ready
'disable_upload_validation' =>  true,       //  using a custom plugin for managing file uploads
'scroll_to_error'           =>  false,      //  don't scroll the browser window to the error message
'tips_position'             =>  'right',    //  position tips with error messages to the right of the controls
'validate_on_the_fly'       =>  false,      //  don't validate controls on the fly
'validate_all'              =>  false,      //  show error messages one by one upon trying to submit an invalid form
));
</code>

To access the JavaScript object and use the public methods provided by it, use $('#formname').data('Zebra_Form')
where <i>formname</i> is the form's name <b>with any dashes turned into underscores!</b>

<i>Therefore, if a form's name is "my-form", the JavaScript object would be accessed like $('my_form').data('Zebra_Form').</i>

From JavaScript, these are the methods that can be called on this object:

-   <b>attach_tip(element, message)</b> -   displays a custom error message, attached to the specified jQuery
element
-   <b>clear_errors()</b>               -   hides all error messages;
-   <b>submit()</b>                     -   submits the form;
-   <b>validate()</b>                   -   checks if the form is valid; returns TRUE or FALSE;
<i>if called with the "false" boolean argument, error messages will
not be shown in case form does not validate</i>

Here's how you can use these methods, in JavaScript:

<code>
//  let's submit the form when clicking on a random button

// get a reference to the Zebra_Form object
var $form = $('#formname').data('Zebra_Form');

// handle the onclick event on a random button
$('#somebutton').bind('click', function(e) {

// stop default action
e.preventDefault();

// validate the form, and if the form validates
if ($form.validate()) {

// do your thing here

// when you're done, submit the form
$form.submit();

}

// if the form is not valid, everything is handled automatically by the library

});
</code>

@param  mixed   $properties     Can have the following values:

-   FALSE, disabling the client-side validation;
<i>Note that the {@link Zebra_Form_Control::set_rule() dependencies} rule will
still be checked client-side so that callback functions get called, if it is
the case!</i>
-   TRUE, enabling the client-side validation with the default properties;

-   an associative array with customized properties for the client-side validation;

In this last case, the available properties are:

-   <b>close_tips</b>, boolean, TRUE or FALSE<br>
Specifies whether the tips with error messages should have a "close" button
or not<br>
Default is <b>TRUE</b>.

-   <b>disable_upload_validation</b>, boolean, TRUE or FALSE<br>
Useful for disabling all client-side processing of file upload controls, so
that custom plugins may be used for it (like, for instance,
{@link http://blueimp.github.io/jQuery-File-Upload/basic.html this one})
Default is <b>FALSE</b>.

-   <b>on_ready</b>, JavaScript function to be executed when the form is loaded.
Useful for getting a reference to the Zebra_Form object after everything is
loaded.

<code>
$form->clientside_validation(array(
// where $form is a global variable and 'id' is the form's id
'on_ready': 'function() { $form = $("#id").data('Zebra_Form'); }',
));
</code>

-   <b>scroll_to_error</b>, boolean, TRUE or FALSE<br>
Specifies whether the browser window should be scrolled to the error message
or not.<br>
Default is <b>TRUE</b>.

-   <b>tips_position</b>, string, <i>left</i>, <i>right</i> or <i>center</i><br>
Specifies where the error message tip should be positioned relative to the
control.<br>
Default is <b>left</b>.

-   <b>validate_on_the_fly</b>, boolean, TRUE or FALSE<br>
Specifies whether values should be validated as soon as the user leaves a
field; if set to TRUE and the validation of the control fails, the error
message will be shown right away<br>
Default is <b>FALSE</b>.

-   <b>validate_all</b>, boolean, TRUE or FALSE<br>
Specifies whether upon submitting the form, should all error messages be
shown at once if there are any errors<br>
Default is <b>FALSE</b>.

@return void
Sets properties for the client - side validation .