Wednesday 20 June 2018

Why type="file" does not Work with Safari Browser? in Contact Form 7


Note: Script Must be written in header

<script>
jQuery(function() {
var input_file = [];
jQuery('form.wpcf7-form').on('submit', function() {
console.log("-------------------------------");
var i = 0;
jQuery('input[type=file]').each(function() {
if (jQuery(this).val() === '') {
jQuery(this).attr('type', 'hidden');
input_file[i++] = jQuery(this).attr('name');
}
});
console.log("Type Change File To Hidden: "+input_file);
});

jQuery( document ).ajaxComplete(function() {
//AJAX RESPONSES
console.log("Array in File item: "+input_file.length);
if(input_file.length > 0){
jQuery.each(input_file, function(key, index){
console.log("Type Change Hidden To File: "+key +'=> '+index);
jQuery('input[name='+input_file[key]+']').attr('type', 'file');
});
input_file = [];
}
console.log("Response: " + jQuery(".wpcf7-response-output").html());
});
});
</script>

Please try this and give your review.

Monday 18 June 2018

Detect Safari Browser Using jQuery

<script>
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1)  {
alert('Now, You are using safari browser...');  
}else{
alert('Now, You are not using safari browser...');
}
</script>


Saturday 16 June 2018

How to Disable Date on Month Change in Datepicker Using jQuery?

I have created disable dates on change month in jQuery UI Datepicker. The Datepicker shows the disable date in Datepicker.

While click on Next or Prev month one Ajax page call for get disable date list.

In this demo, I have set a random date to disable. But you can set disable dates list in JSON format as per your requirement.

This demo will take little time for disabling date in Datepicker. Because of every change month in call callAJAX only for this month.



Download this Scrip Code of Disable Datepicker Click Here

Saturday 9 June 2018

How to temporarily disable a button click in jQuery?

<script>
$("#button_id").click(function() {
  if($(this).data('dont')==1) return;
  $(this).data('dont',1);

  // Do Process .....

  $(this).data('dont',0);
}

///////// OR /////////

$("#button_id").click(function() {
  if($("#button_id").data('dont')==1) return;
  $("#button_id").data('dont',1);

  // Do Process .....

  $("#button_id").data('dont',0);
}
// Note: Remeber that $.data() would work only for items with ID.
</script>