DatePicker Suggestions
Hi,
I'm using WA DatePicker directly rather than through form builder today and I have a couple of suggestions.
In addition to the earlier Template discussion, it would be great if the behavior allowed an initial value and even handled the formatting of the initial value, e.g.:
value="<?php echo ($rs["mydate"])?date("m/d/Y",strtotime($rs["mydate"])):""; ?>"
Also, I think the code could be improved by changing the close function to accept any element like so:
<script type="text/javascript">
$(function(){
$('#mydate').datepicker({
dateFormat: 'mm/dd/yy',
showAnim: 'show',
onClose: closeDatePicker("mydate")
});
});
function closeDatePicker(eid) {
var tElm = $("#"+eid);
if (typeof datepicker_1_Spry != null && typeof datepicker_1_Spry != "undefined") {
datepicker_1_Spry.validate();
}
var docElm = document.getElementById(eid);
var tBlur = docElm.getAttribute("onBlur");
if (!tBlur) tBlur = docElm.getAttribute("onblur");
if (!tBlur) tBlur = docElm.getAttribute("ONBLUR");
if (tBlur) {
tBlur = tBlur.replace(/\bthis\b/g, "docElm");
eval(tBlur);
}
}
</script>
I'm not sure why the extension code does not stay with jQuery (document.getElementById) but if it could it should. I assume there is a good reason for this.
It would be really nice if the behavior were editable through the GUI. I also see that WA adds some files under webassist/datepicker/edit_datepicker1, so a second parameter may be necessary to have different styled or validated fields on one form.