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
698

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 check the PHP version
  • How to PHP Get Max Value From Array
  • How to Reverse A String with JavaScript
  • How to add page numbers in PDF in CodeIgniter
  • How to move an entire div element up x pixels with CSS?
  • 4 Methods to Search an Array

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

Dealing with deprecations
HTML Basic Examples
How to Use useLocation Hook in React Router DOM V6
How to make the div move up and down when scrolling the page with CSS?
Git basics: The simple commands to begin with

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved