Tuesday, 19 August 2014

Input field JQuery float validation, decimal validation

$('#price').keyup(function(e){
      var entered_value = $(this).val();
  var regexPattern = /^\d{0,8}(\.\d{1,2})?$/;         
      //Allow only Number as well 0nly 2 digit after dot(.)
      if(regexPattern.test(entered_value)) {
        alert("false") ;  
      } else {
         alert("true");
      }
});

Monday, 18 August 2014

How to take dates between two dates in php?

   $task_to_do = array();
   echo "
"; $s = strtotime("START_DATE"); $d = strtotime("END_DATE"); $dif = 86400; $i=$s; $x=0; while ($i <= $d) { $dat = date("Y-m-d 00:00:00",$i); $t_s = date("Y-m-d 00:00:00",strtotime($dat)); $t_e = date("Y-m-d 23:59:59",strtotime($dat)); $task_to_do[$x]["start_date"] = $t_s; $task_to_do[$x]["end_date"] = $t_e; $i = $i+$dif; $x++; } echo "
";
   print_r($task_to_do);

Sunday, 17 August 2014

Disable Hotlinking Images from Searchengines with htaccess

The following code is used to prevent HotLinking to jpg, jpeg, gif, png, and bmp file types.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?your-websitename.com/.*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ - [F]