HOW TO add my own JavaScript validation for search fields?

Talk and info about common issues

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

administrator
Site Admin
Site Admin
Posts: 5988
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO add my own JavaScript validation for search fields?

Postby administrator » Mar 9th, '12, 12:49

To add you own JavaScript validation for search (filtering) fields, use a 'on_js_event' property of the filtering fields.

Example:
1. Define anywhere on your page checkFilteringFields() function:

Code: Select all

<script type="text/javascript">
    function checkFilteringFields(val){
         if(val != '' && val.length < 3){
             alert('The length of the name cannot be less than 3 chars!');
         }
    }
</script>

2. Specify in appropriate filtering field a call for checkFilteringFields() function in a following way:

Code: Select all

'Name'=>array('type'=>'textbox', 'table'=>'customers', ..., 'on_js_event'=>'onblur="checkFilteringFields(this.value)"'),

Return to “ApPHP DataGrid {HOW TO}”