Hello,
To improve page rendering performance on a page with alot of date/time input fields, I'm trying to dynamically replace standard input textboxes with raddate/timepickers as the textboxes are selected, however I'm having trouble setting the text inside the date/time pickers. As soon as the picker gets focus it replaces the value in its textbox with whatever the selected datetime is. I need the value to "stick" when the picker gets focus, even if it is not valid.
Here's the code I'm using right now:
I know I can always parse the datetime represented in the textbox and then call set_selectedDate() on the picker, but I need to be able to set values with invalid formats as well, and it would be nice if I could rely on the parsing mechanism inside the picker.
To improve page rendering performance on a page with alot of date/time input fields, I'm trying to dynamically replace standard input textboxes with raddate/timepickers as the textboxes are selected, however I'm having trouble setting the text inside the date/time pickers. As soon as the picker gets focus it replaces the value in its textbox with whatever the selected datetime is. I need the value to "stick" when the picker gets focus, even if it is not valid.
Here's the code I'm using right now:
| <input type="text" onfocus="onTimeInputFocus(this);"/> |
| <script type="text/javascript" language="javascript"> |
| var replacedElement = null; |
| function onTimeInputFocus(input) |
| { |
| timepicker = getNinjaTimePickerObject(); |
| timepickerEl = getNinjaTimePickerElement(); |
| if ( replacedElement ) |
| { |
| replacedElement.value = timepicker.get_textBox().value; |
| timepickerEl.parentNode.replaceChild(replacedElement, timepickerEl); |
| } |
| else |
| { |
| timepickerEl.parentNode.removeChild(timepickerEl); |
| } |
| replacedElement = input.parentNode.replaceChild(timepickerEl, input); |
| timepicker.get_textBox().value = replacedElement.value; |
| //setTimeout( "timepicker.get_textBox().focus();", 100 ); |
| } |
| function getNinjaTimePickerElement() |
| { |
| return document.getElementById("<%= NinjaTimePicker.ClientID %>" + "_wrapper"); |
| } |
| function getNinjaTimePickerObject() |
| { |
| return $find("<%= NinjaTimePicker.ClientID %>"); |
| } |
| </script> |
I know I can always parse the datetime represented in the textbox and then call set_selectedDate() on the picker, but I need to be able to set values with invalid formats as well, and it would be nice if I could rely on the parsing mechanism inside the picker.