ทำ Input Box ให้แสดงปฏิทินแบบไทย วัน เดือน ปี พ.ศ.

bootstrap-datepicker ภาษาไทย


Head

/**เรียกใช้ bootstrap-datepicker ภาษาไทย**/

<head>
<!-- font-awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"> <!-- bootstrap@5.1.3 --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <!-- jquery@3.6.0 --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<!-- Bootstrap DatePicker --> <link href="https://semicon.github.io/bootstrap-datepicker-thai/css/datepicker.css" rel="stylesheet"> <script src="https://semicon.github.io/bootstrap-datepicker-thai/js/bootstrap-datepicker.js"></script> <script src="https://semicon.github.io/bootstrap-datepicker-thai/js/bootstrap-datepicker-thai.js"></script> <script src="https://semicon.github.io/bootstrap-datepicker-thai/js/locales/bootstrap-datepicker.th.js" charset="UTF-8"></script> </head>


Body

/**กำหนดให้ datepicker แสดงในกล่องข้อความด้านล่าง**/

<div class="row justify-content-md-center p-4"> <div class="col-md-auto py-2"> <div class="col-12"> <input class="form-control" type="text" name="datepicker" id="datepicker" placeholder="เลือก วัน เดือน ปี" readonly/> </div> </div> </div>


javascript

/**ใช้ jquery เรียกใช้ datapicker **/

<script type="text/javascript"> $(document).ready(function () { $('#datepicker').datepicker({ format: 'dd-mm-yyyy', language:'th-th', autoclose: true, }); }); </script>


2 ความคิดเห็น

แสดงความคิดเห็น
ใหม่กว่า เก่ากว่า