jQuery datepicker not opening up on focus -


heres scenario: have index page 2 radio buttons on , span area results. when 1 of radio buttons clicked, span fills ajax generated page has input box :

<input size='25' class='datepicker' value='click enter deposit date' readonly type='text'    id='depositdate' name='depositdate'>  

at bottom of page there 'add record' button fires off javascript validation. validation so:

var inpdepdate  = $.trim($("#depositdate").val()); if(inppaydate=='click enter pay date') // validate pay date {     alert('invalid pay date; re-enter');      document.getelementbyid('paydate').focus();     document.getelementbyid('paydate').select();      return false; } 

also in javascript file :

$(function(){     $( "#depositdate" ).live('focus', function() {         $(this).datepicker({             changemonth: true,             changeyear: true,             mindate: "+1d",             showothermonths: true,             selectothermonths: true}).focus();     }); }); 

the problem when validation fails, text highlighted , selected not open automatically.

ive tried number of things, ton of things site, , no luck. , seems never recognize live event. if click on text box after failed validation (and text highlighted), calendar opens fine. im new @ jquery , ui.

you don't need reinstantiate datepicker if you've called on #depositdate in past. (or on paydate)

try this:

if(inppaydate=='click enter pay date') // validate pay date {     alert('invalid pay date; re-enter');      $("#paydate").datepicker("show");     return false; } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -