Step
1.add textbox
2.import js
3.bind textbox & datepicker
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <script src="https://code.jquery.com/jquery-3.6.0.js"></script> <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script> <script type="text/javascript"> $(function () { $("#txt_DATE").datepicker({ dateFormat: 'yy/mm/dd' }).val(); }); </script></head><body> <input id="txt_DATE" type="text" /></body></html>
结果:
画面就会像这样,点一下txt_DATE,会跳出日曆可以选日期,选完日期,值放到txt_DATE
*日期会依我们设的dateformat做显示.
aspx的control也可以
<asp:TextBox ID="txt_DATE" runat="server"></asp:TextBox>
ref
js datepicker
https://jqueryui.com/datepicker/
datepicker format
https://stackoverflow.com/questions/1328025/jquery-ui-datepicker-change-date-format