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
697

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 Send Email from Localhost in PHP
  • How to Disable WordPress Auto Update? Turn Off WordPress Auto Updates
  • How to Delete and Remove Files on Ubuntu Linux Terminal
  • How to Symfony Request
  • How to Delete Unused Database Tables in WordPress
  • Difference between var, let, and const in JavaScript

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 Symfony parameters and environment variables use
How to make a div always float on the screen in the top right corner with CSS?
How to trigger a button click from another button click event with JavaScript?
How to Convert PHP CSV to JSON
How to Search Recently Modified Files in Linux

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved