[英]Javascript Prompt dialog customize input
Example with date input:日期输入示例:
const {
value: formValue
} = await Swal.fire({
title: 'Select a date',
html: '<input type="date" id="swal-input" class="swal2-input">',
focusConfirm: false,
allowOutsideClick: false,
preConfirm: () => {
return document.getElementById('swal-input').value;
}
})
The result of running this will be a popup in the center of the screen with a date input box:运行此命令的结果将是在屏幕中央弹出一个带有日期输入框的窗口:
The selected date will be stored in the variable called formValue
.选定的日期将存储在名为formValue
的变量中。
To get started quickly, you can include this script at the beginning of the HTML:为了快速开始,您可以在 HTML 的开头包含此脚本:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
If I understand your needs I think you can use jQuery datepicker https://jqueryui.com/datepicker/#default如果我了解您的需求,我认为您可以使用 jQuery datepicker https://jqueryui.com/datepicker/#default
if you want the calendar to be inline you can do that too https://jqueryui.com/datepicker/#inline如果您希望日历内联,您也可以这样做https://jqueryui.com/datepicker/#inline
The source code is at the bottom of the pages.源代码位于页面底部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.