[英]prevent keyboard from popping up on datepicker mobile
I have this page with a booking widget and date picker here:我在这里有一个带有预订小部件和日期选择器的页面:
http://anivillas.com/ http://anivillas.com/
(Book your stay) (预订您的住宿)
The following code is set to try and prevent the keyboard from coming up on mobile devices when choosing the datepicker.以下代码设置为在选择日期选择器时尝试防止键盘出现在移动设备上。
<script type="text/javascript">
jQuery(function() {
jQuery( ".hasDatepicker" ).hasDatepicker({
}).attr('readonly','readonly');
});
</script>
This is working on desktop but not mobile devices.这适用于台式机,但不适用于移动设备。 Does someone know how to prevent the keyboard from popping up on mobile?
有人知道如何防止键盘在手机上弹出吗?
Try this (taken from ipad web application: How do I prevent the keyboard from popping up on jquery datepicker ): 尝试以下操作(取自ipad Web应用程序:如何防止键盘在jquery datepicker上弹出 ):
$(".datePicker").datepicker({
showOn: 'button',
onClose: function(dateText, inst)
{
$(this).attr("disabled", false);
},
beforeShow: function(input, inst)
{
$(this).attr("disabled", true);
}
});
For others looking for this answer, this is answered here: prevent iphone default keyboard when focusing an <input>对于寻找此答案的其他人,请在此处回答: 在聚焦 <input> 时防止 iphone 默认键盘
Either of these worked for me - edit the HTML tag as follows, rather than adding JS or jQuery:这些都对我有用 - 按如下方式编辑 HTML 标记,而不是添加 JS 或 jQuery:
<input ... readonly="readonly">
<input ... inputmode='none'>
Simply add the ' readonly ' attribute to the form filed:只需将“只读”属性添加到表单字段:
<input id="datepicker" type="text" name="name" required="" readonly>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.