2014-01-28 42 views
0

我已經試過這種如何綁定模糊和焦點事件阿賈克斯組合框

$('#<%= txtSponsorBC2.ClientID %>').focus(function() { 
     var selectedDate = $('#txtMandateDate').datepicker('getDate'); 
     var currentDate = new Date(); 
     currentDate.setHours(0); 
     currentDate.setMinutes(0); 
     currentDate.setSeconds(0); 


     if ($("#txtMandateDate").val() != "" && $("#txtMandateDate").val() != "dd/mm/yyyy") { 
      if (Date.parse(selectedDate) < currentDate) { 
       return true; 
      } 
      else { 
       alert(" date cannot be future date"); 
       return false; 
      } 
     } 

    }); 

如果我使用$('#<%= txtSponsorBC2.ClientID %>')訪問AJAX組合框我得到一個錯誤的東西

Microsoft JScript runtime error: Syntax error, unrecognized expression: #<%= txtSponsorBC2.ClientID %> 

回答

0

嘗試$('#'+<%= txtSponsorBC2.ClientID %>)代替