2014-01-21 61 views
1

我有以下代碼 ,但它不工作的某種原因 第一個工作bt第二個輸入框不工作,我想禁用幾個日期。禁用日期選擇不起作用-jquery

它是在小提琴 http://jsfiddle.net/arunpjohny/CxNNh/1/

<!doctype html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<title>jQuery UI Datepicker - Default functionality</title> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> 
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 

<script> 

var array = ["2013-03-14","2013-03-15","2013-03-16"] 

$('input').datepicker({ 
    beforeShowDay: function(date){ 
     var string = jQuery.datepicker.formatDate('yy-mm-dd', date); 
     return [ array.indexOf(string) == -1 ] 
    } 
}); 



$(function() { 
$("#datepicker").datepicker(); 
}); 
</script> 
</head> 
<body> 
<p>Date: <input type="text" id="datepicker"></p> 
<input /> 

</body> 
</html> 

回答

1

工作正常,我自己解決,並認爲是有很多意見,將有助於some1但沒有1能夠回答

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <title> by Suraj Mishra</title> 

    <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script> 



<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/redmond/jquery-ui.css"> 


<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script> 


    <style type='text/css'> 

    </style> 



<script type='text/javascript'>//<![CDATA[ 


$(window).load(function(){ 



var array = ["2014-01-11","2014-01-12","2014-01-10"] 

$('input').datepicker({ 
    beforeShowDay: function(date){ 
     var string = jQuery.datepicker.formatDate('yy-mm-dd', date); 
     return [ array.indexOf(string) == -1 ] 
    } 
}); 
}); 


//]]> 

</script> 


</head> 
<body> 
    <input /> 

</body> 


</html>