Category: Jquery

jQuery setTimeout() function

If we want to run a block of code after a specified time means we can use jQuery setTimeout() method. What it will do is, it will run specified code at specified millisecond. Syntax for this method is setTimeout(code,milliseconds). jQuery(document).ready(function () { jQuery(‘.submit’).click(function(){ var T = setTimeout(showAlert, 3000); });});function showAlert(){ alert("Its fired after 3 seconds");} […]

Read More…

Clear form fields after finishing ajax submit using Jquery

Use reset() method to clear form fields after submitting the form via ajax. $.ajax({ type:"POST", url:formUrl, data:formData, beforeSend:function(){ $(‘.status’).html(‘<b>Form is being submitted</b>’); }, success:function(data){ $(‘. status ‘).html(‘<b>Thank you!! We have received your form</b>’); }, complete:function(){ $(‘#form-id’).each(function(){ this.reset(); //Here form fields will be cleared. }); }});

Read More…

Disable paste option in textbox

With the help of jQuery event.preventDefault() method we can disable paste in textbox. It can be used in the situation where user enters his confirmation email id in registration form. $(‘#confirm-email’).bind("paste",function(e) { e.preventDefault(); alert(‘You cannot pase text into this textbox’);}); Some other events: cut,copy,contextmenu(disables right click) $(‘#confirm-email’).bind("cut copy contextmenu paste",function(e) { e.preventDefault();}); It will prevent […]

Read More…

Using wordpress admin ajax

Using wordpress admin ajax is very simple. You need to follow this steps accordingly. Create a function to display your form in front end. You can use short code to include your form in post/page. Make sure you must have action filed in form, with the help of action value you can access wp_ajax hook. […]

Read More…