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
1,272

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

  • 4 Methods to Search an Array
  • How to Use useLocation Hook in React Router DOM V6
  • How to Change SSH Port in Linux
  • How to change background Opacity when the bootstrap modal is open with CSS?
  • How to check if a customer is logged in to Magento 2 or not?
  • How to Enable Debug Mode in Laravel

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

How to style an HTML radio button to look like a checkbox with CSS?
How to change password in the CodeIgniter framework
How to Convert PHP CSV to JSON
How to Deploy a React application on a cPanel
How to Check Twig Version in Symfony

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved