Skip to main content


Showing posts from May, 2015

Check All by jQuery

Check All by jQuery Method 1:  $(document).ready(function() {     $('#selectAll').click(function(event) {         if(this.checked) { // check select status             $('.checkbox1').each(function() {                 this.checked = true;  //select all checkboxes with class "checkbox1"                         });         }else{             $('.checkbox1').each(function() {                 this.checked = false; //deselect all checkboxes with class "checkbox1"                                 });               }     });   }); Html <div> <input type="checkbox" id="selectAll">Check All </div> <div> <input type="checkbox" class="checkbox1">Home <input type="checkbox" class="checkbox1">About <input type="checkbox" class="checkbox1">Page </div> Method 2:  $("#checkAll").clic

Sort Table by jquery

1.  Sort table first column by jQuery Create a function sortTable. Pass table id & order function sortTable(table, order) {             var asc   = order === 'asc',             tbody = table.find('tbody');          tbody.find('tr').sort(function(a, b) {         if (asc) {             return $('td:first', a).text().localeCompare($('td:first', b).text());         } else {             return $('td:first', b).text().localeCompare($('td:first', a).text());         }     }).appendTo(tbody); } Call function when document loaded jQuery(document).ready(function() { sortTable($('#editable'),'asc'); }); 2. Sort the select option without empty value Html: <select id="contacts" class="filteroption" name="data[Candidateprofile][company]"> <option value="">Contact</option> <option value="1">John</option> <op

How to add Validation rule in jQuery validation Plugin

How to add Validation rule in jQuery validation Plugin 1. Load the validate plugins <script src="js/jquery.validate.js"></script> 2. Now call the jQuery validate method <script> $(document).ready(function(){ // Add your own custom method  $("#old_password").rules('add',{remote:"check_password.php",  messages: {remote: "Passwords do not match"}});  $("#confirm_password").rules('add',{equalTo: "#password",   messages: {equalTo: "New password and confirm password do not match"}}); }); controller action $count=$this->Member->find('count',array( 'conditions'=>array('Member.password'=>md5($_GET['oldPass']), ''=>$this->Session->read(''))));    if($count>0)    { echo 'true'; die;    } else { echo 'false'; die;   } // valid