Uncaught TypeError: Cannot set property 'currentDay' of undefined-Collection of common programming errors

I have a textfield1 and a textfield in a modal, When I click on textfield1 it appears fine, but when I click on the textfield present in the modal the datepicker appears but on selecting the date gives this error

After much googling and searching about same error I found that it could be because of same IDs of textfield but i ensured that both have different IDs, I dont know what is actually causing the problem Here is my code

      
$(function() {
    $("body").delegate("#tx1, #tx2", "focusin", function(){
        $(this).datepicker();
    });
});

  

EDIT These are the libraries