我決定使用JQuery UI Datepicker腳本來選擇日期。下面是我的代碼的一部分,我的方式集成到我的PHP頁面:如何禁用JQuery UI Datepicker字段的手動輸入?
<link type="text/css" href="css/south-street/jquery-ui-1.8.6.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
<script type="text/javascript">
$(function(){
// Datepicker
$('#datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
//hover states on the static widgets
$('#dialog_link, ul#icons li').hover(
function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
);
});
</script>
和:
// date picker (embeds JQuery script)
echo '<label for="datepicker">Date: </label>';
echo '<input type="text" name="datepicker" id="datepicker" />';
echo '<div id="datepicker"></div>';
差不多根據JQuery用戶界面的說明。
現在我的問題是:如何禁用文本輸入字段中的手動輸入?我只希望JQuery Datepicker腳本能夠填充文本字段。據我所見,該腳本目前阻止用戶在文本字段中輸入任何非數字字符,但允許任何數字組合(因此,允許使用「95460829468」之類的亂碼)。
令人驚訝的簡單的解決方案。似乎按預期工作,非常感謝! – BeeDog 2010-11-12 12:34:08
如果添加'background-color:#fff!important;光標:文本!重要;'它看起來完全正常... – 2014-08-05 12:51:48
我會使用光標指針,使其看起來可點擊 ' ' – 2014-08-18 12:27:03