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
868

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 use the Local Storage in Javascript
  • How to Search Recently Modified Files in Linux
  • How to Change SSH Port in Linux
  • How to Disable WordPress Auto Update? Turn Off WordPress Auto Updates
  • How to Create Live Search in HTML table with jQuery
  • How to PHP Get Max Value From 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

Enable or Disable SSH Root Login Access in Linux
How to use setTimeout and setInterval methods in JavaScript
How to Reverse A String with JavaScript
How to Convert PHP CSV to JSON
Important most things you should know about JSX

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved