December 01, 2013

How to Enable, Disable, Remove, Attach Jquery DatePicker?

<script>
        var jq = jQuery.noConflict();
</script>
<script>
    jq(function() {
    jq( "#dobDtpicker" ).datepicker({ changeMonth: true, changeYear: true, yearRange: '1900:2055', numberOfMonths: 1, dateFormat: "dd/mm/yy", showOn: "button",buttonImage: "images/date.gif", buttonImageOnly: true });
    });
</script>

<style type="text/css">
    div.ui-datepicker{
    font-size:10px;
    width: 17%;
    height: 30%;
    }
</style>

..............................
...............................................
.......................
<table>
<tr>
<td>Date of Journey:</td>
<td>
<html:text property="dob" readonly="true" styleId="dobDtpicker" size="10" />
>/td>                                       
</table>

To attach and remove the datepicker to a control use below methods :-

Attach:
 jq(#dobDtpicker).datepicker();

Remove:

 jq(#dobDtpicker).datepicker("destroy");

Enable:

 jq(#dobDtpicker).datepicker('enable');

Disable:

 jq(#dobDtpicker).datepicker('disable');

-K Himaanshu Shukla..





Copyright © 2013 - ScrutinyByKHimaanshu

No comments:

Post a Comment