开发者

How to call change function from jquery datepicker onselect

I have below function for my jQuery Datepicker.

$(doc开发者_JAVA百科ument).ready(function() 
{        
    $(".txtDate").datepicker({
    showOn: 'button',
    buttonImage: '../images1/calendar.gif', 
    buttonImageOnly: true,
    dateFormat: 'dd/mm/yy',      
    showOtherMonths: true,
    showStatus: true,
    onSelect:function(){}
    });
    $('.ui-datepicker-trigger').attr('alt', 'Date').attr('title', 'Select Date').attr('align', 'absMiddle');
});

Now I want to call change function onSelect Please see below

onSelect:function(){}
        });


 $(document).ready(function() 
   {    
            var zeroPad = function(num) 
            {
                    var s = '0'+num;
                    return s.substring(s.length-2)           
              };

        $('#ctl00_ContentPlaceHolder2_FormView1_ApprovedDTTextBox').change(function () 
        {
            var value = $(this).val();
            var regex = /^\d{2}\/\d{2}\/\d{4}$/;      

            if (regex.test(value)) 
            {                         

                  var myDate = new Date(Date.parse(reformat(value)));              
                  $('#ctl00_ContentPlaceHolder2_FormView1_ExpiryDTTextBox').val (zeroPad(myDate.getDate()) + '/' + 
                        zeroPad(myDate.getMonth() + 1) + '/' + (myDate.getFullYear() + 3));
                        $("#ctl00_ContentPlaceHolder2_FormView1_ExpiryDTTextBox").focus();
            } 
            else 
            {
                  //alert('invalid date');   
                  $('#ctl00_ContentPlaceHolder2_FormView1_ApprovedDTTextBox').val('');
                  $("#ctl00_ContentPlaceHolder2_FormView1_ApprovedDTTextBox").focus();
            }   
        });
});        

Please suggest as it giving error of length null in IE Explorer and working fine in Mozilla, as well as it is not calling change(); function, It is working fine with blur but for that I need to do blur, however I want this functionality on change.


Are you aware that the Jquery UI library has a datepicker function with many themes? And you can invoke it on any input field with a single line like this:

$('#myfav').datepicker();

Of course you can add your options there too if needed. And the Jquery UI library has many themes.

http://docs.jquery.com/UI/Datepicker

Not the answer you're looking for, but hope it helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜