codegeek codegeek - 2 years ago 254
jQuery Question

Bind jquery UI date-picker on focus of input element

Hi i have a situation like i need to bind the jquery UI datepicker({}) function when the input element is focused.i am not able to achieve it with the below code ,so guys plz help how can i bind the datepicker function when the input element is focused

<!DOCTYPE html>
<link rel="stylesheet" href="">
<title> Jquery UI Date Picker </title>

<input type="text" id="date" />

<script src=""></script>
<script src=""></script>

Answer Source

You can open datepicker using onclick event:

<input type="text" id="date" onclick="$('#date').datepicker();$('#date').datepicker('show');" />


$( "#date" ).focus(function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download