Posts

Showing posts from March, 2018

Autofill forms

 Remove autofill field in form:  Use autocomplete="cc-blank" into input html attribute.

PHPExcel Tricks

=> Date format conversion in PHP Excel: - When import excel file you have other date format and save date like database format (eg. 17-11-17 into 2017-11-17) you have write below code:  $BookingMade = " 17-11-17 "; $BookingmadeDate = date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($BookingMade)); Output: 2017-11-17

Datatable Tricks

=> In datatable redirect baseurl when session is expired:    - In datable.js file write following code:  "data": function (d) {                 $.getJSON('contacts/ajaxData',myData, function (json) {                     if (json.expired == '1') {                         window.location = BASE_URL;                     }                 });                 return  $.extend(d, myData);          ...

PHP: Trim and Filter Array

=> Trim and Filter Array:    $array = array("apple", "", 2, null, -5, "    orange ", 10, false, "   ");    echo "<pre>";print_r($array);echo "</pre><br>";   // trim the array  $result_2 = array_map('trim',$array);             echo "<pre>";print_r($result_2);echo "</pre><br>";    // Filtering the array $result = array_filter($array);                 echo "<pre>";print_r($result);echo "</pre><br>"; 

Jquery short tricks

=> jQuery for select tomorrow’s date:     jQuery("#deliverydate1").datepicker("setDate", "1"); => jQuery validation for trim name and email:             var name1 = jQuery.trim(jQuery('input[name=name]').val());      console.log("TRIM " + name1);     var pattern = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|   [0-9]{1,3})(\]?)$/;     console.log(jQuery.trim(jQuery('input[name=email]').val()).match(pattern) ? true : false);