Skip to content
  • Homepage
  • HTML
  • CSS
  • Symfony
  • PHP
  • How to
  • Contact
  • Donate

Teach Developer

Articles, Guides & Tips

How to Add Reset Button in jQuery UI Datepicker

Home  »  How to • Jquery   »   How to Add Reset Button in jQuery UI Datepicker
Posted on September 3, 2022September 17, 2022
945

I am using the jQuery UI date picker plugin to add the date picker dialog to the text input field. Since the input field is a read-only element, it is not allowed to clear the selected date. Is there any option to add a reset button in the date picker to clear the date from the input field as well as the date picker?

Here is my code to attach the date picker to the HTML input element using the jQuery UI library.

<input type="text" id="datepicker" readonly="readonly">
$(function(){
    $("#datepicker").datepicker({
      showOn: 'focus',
      showButtonPanel: true,
      closeText: 'Reset', // Text to show for "close" button
      onClose: function () {
          var event = arguments.callee.caller.caller.arguments[0];
          // If "Reset" gets clicked, clear selected value
          if ($(event.delegateTarget).hasClass('ui-datepicker-close')) {
              $(this).val('');
          }
      }
    });
});
How to, Jquery Tags:Javascript, JQuery

Post navigation

Previous Post: How to Display Breadcrumb without Plugin in WordPress
Next Post: How to Enable Debug Mode in Laravel

Related Posts

  • How to Recover Deleted WhatsApp Messages
  • How to move an entire div element up x pixels with CSS?
  • How to change background Opacity when the bootstrap modal is open with CSS?
  • How to check the PHP version
  • How to fix getFullyear() is not a function with JavaScript?
  • How to use events listeners and Event Subscriber in Symfony

Categories

  • Codeigniter (3)
  • CSS (11)
  • eCommerce (1)
  • Framework (1)
  • Git (3)
  • How to (43)
  • HTML (5)
  • JavaScript (15)
  • Jquery (7)
  • Laravel (1)
  • Linux (4)
  • Magento-2 (1)
  • Node js (4)
  • Others (2)
  • PHP (11)
  • React (13)
  • Server (1)
  • SSH (3)
  • Symfony (6)
  • Tips (16)
  • Top Tutorials (10)
  • Ubuntu (3)
  • Vue (1)
  • Wordpress (7)

Latest Posts

  • What is SSH in Linux?
  • How to Delete Files in Ubuntu Command Line
  • How to Deploy a React application on a cPanel
  • How to use events listeners and Event Subscriber in Symfony
  • How to Convert PHP CSV to JSON

WEEKLY TAGS

AJAX (1) Codeigniter (1) Javascript (11) JQuery (1) PHP (16) Programming (1) React (3) Symfony (1)

Random Post

Difference between var, let, and const in JavaScript
How to split a string into an array with Twig
Important most things you should know about JSX
How to Delete Unused Database Tables in WordPress
How to Enable Debug Mode in Laravel

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved