亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我想使用 PHP 和 mysql 禁用 html 日期選擇器(輸入類型=“日期”)的某些未來日期

我想使用 PHP 和 mysql 禁用 html 日期選擇器(輸入類型=“日期”)的某些未來日期

PHP
慕標琳琳 2023-07-30 13:11:10
我想input type="date"使用 PHP 和 MySQL 禁用 HTML 日期選擇器 ( ) 的某些未來日期。有人可以幫我做到這一點嗎?我試圖做到這一點,并通過 Google 搜索,但沒有找到使用 PHP 和 MySQL 禁用某些日期的方法。
查看完整描述

1 回答

?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

這是一個演示。這使用 Bootstrap datepicker 和 jquery。另外,我在代碼內的注釋中提到了在哪里使用 php


<!DOCTYPE html>

<html>

<head>

    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.css">

    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.css">

    <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.js"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

</head>

<body>

   

<div class="container">

    <input type="text" name="date" class="form-control datepicker" autocomplete="off">

</div>

   

</body>

  

<script type="text/javascript">

    // This can come from php

    // var disableDates = [<?php //echo $your_variables_from_php_mysql_printed_in_the_format_below; ?>]

    var disableDates = ["7-7-2020", "14-7-2020", "15-7-2020","27-7-2020"];

      

    $('.datepicker').datepicker({

        format: 'mm/dd/yyyy',

        beforeShowDay: function(date){

            dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();

            if(disableDates.indexOf(dmy) != -1){

                return false;

            }

            else{

                return true;

            }

        }

    });

</script>

</html>


查看完整回答
反對 回復 2023-07-30
  • 1 回答
  • 0 關注
  • 139 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號