我使用datepicker和输入表单作为输入日期。有时需要,因为更好的速度只能从没有数据贴纸的键盘输入数字。如何允许格式输入字段日期(type=text)
,按逗号并在同一时刻显示输入字段中的点(用点替换逗号)。这是因为键盘数字键盘只有一个逗号而不是一个点。现在我不能逗逗。现在允许只是点。
脚本
<script>
$(function() {
$( "#dokumentdatum" ).datepicker( { changeMonth: true , changeYear:
true, yearRange:"-100:+100", dateFormat: "dd.mm.yy",
dayNamesMin: ["Su", "Ne", "Po", "Ut", "Sr", "Če", "Pe"],
monthNamesShort: [ "Sij", "Vel", "Ožu", "Tra", "Svi", "Lip", "Srp", "Kol", "Ruj", "Lis", "Stu", "Pro" ],
firstDay: 2, showOn: "button", buttonText: 'Odaberi datum', buttonImageOnly: true, buttonImage: 'http://jqueryui.com/resources/demos/datepicker/images/calendar.gif' ,
onClose: function()
{ this.focus(); }
} );
$(".ui-datepicker-trigger").mouseover(function() {
$(this).css('cursor', 'pointer');
});
});
</script>
PHP
<p><label class="field4" for "Dokumentdatum">Datum dokumenta : </label> <input type="text" id="dokumentdatum" onblur="prepisidatumdvo(this)" name="dokumentdatum" value="'.$dokumentdatum.'" placeholder="dd.mm.yyyy" size="10" class="textbox-xx" ></p>
答案 0 :(得分:1)
maxlength中的属性不是大小,因此在输入字段中设置maxlength = 10.我猜你还需要用日期格式验证输入字符串。你可以试试这个:
order by id desc limit 1
答案 1 :(得分:0)
Datepicker现在看起来像这样。重要的是在关闭时添加,因为当您从日历中选择日期时需要。
$(function() {
$( "#dokumentdatum" ).datepicker( { changeMonth: true , changeYear: true, yearRange:"-100:+100", dateFormat: "dd,mm,yy",
dayNamesMin: ["Su", "Ne", "Po", "Ut", "Sr", "Če", "Pe"],
monthNamesShort: [ "Sij", "Vel", "Ožu", "Tra", "Svi", "Lip", "Srp", "Kol", "Ruj", "Lis", "Stu", "Pro" ],
firstDay: 2, showOn: "button", buttonText: 'Odaberi datum', buttonImageOnly: true, buttonImage: 'http://jqueryui.com/resources/demos/datepicker/images/calendar.gif' ,
onClose: function()
{
var data;
data=$('#dokumentdatum').val();
var str=data.replace(/\,/g,".");
$('#dokumentdatum').val(str.replace(/\.\.+/g, '.'));
this.focus();
}
} );
$(".ui-datepicker-trigger").mouseover(function() {
$(this).css('cursor', 'pointer');
});
});