jQuery's datepicker delete issue -


i seem having problem date picker. here current code have:

jquery:

$("txtdate").datepicker({ showon:"both", buttonimage:"calendar.png", buttonimageonly:true, onclose: function() { // here } }); 

html:

<asp:textbox id="txtdate" runat="server" /> 

this works fine until user deletes character textbox after selecting date. example, if user selects 01-01-2013, , deletes last digit, i.e. 3, other date selections after have last digit missing until different year selected.

how stop happening? basically, if user deletes characters selected date, selecting same date again or other date should not result in last character missing.

firstly, $("txtdate").datepicker({...}) target element called "txtdate" (<txtdate></txtdate). jquery selectors work css selectors, , in order target element id you'll need prefix #:

$("#txtdate".datepicker({...}); 

secondly, depending on how workspace set up, asp.net adds somewhat random characters beginning of id ensure remains unique throughout page. means actual markup end looking along lines of:

<input id="ct100_ct109_txtdate" ... /> 

for reason, you'll need target other element's id or pass id javascript through asp.net.

--

i think asif's comment best solution problem: set text box readonly prevent content being modified directly user. in asp.net, done using readonly:

<asp:textbox id="txtdate" runat="server" readonly="true" /> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -