To hide a datepicker you need to
- destroy the datepicker functionality from the input text field
- hide the input text field
To show a datepicker you need to
- show the input text field
- add to it the datepicker functionality
Here is the demo: http://jsfiddle.net/ezKwN/
function hideIt(){
$( "#frdate" ).datepicker( "destroy" );
$( "#frdate" ).hide();
}
function showIt(){
$( "#frdate" ).show();
$( "#frdate" ).datepicker();
}
I don't know if this works for Struts2 jQuery datepicker too, but i hope so.
But consider that using that tag, you are hard-coding that funcionality to the page, it is not supposed to be dynamic, then (if the above solution doesn't work), if you need to show / hide it according to user interactions, you should consider using the native jQuery datepicker instead of the Struts2 one (only for the dynamic datepicker)
EDIT: as another option (with an smaller impact than recoding all your datepickers with native jQuery), you can simply encapsulate the tag inside a <div>
, and hide / show the div.