Laravel:日期选择器不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45186108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:19:56  来源:igfitidea点击:

Laravel: datepicker is not working

phpjquerylaraveljquery-uijquery-ui-datepicker

提问by Nelson Katale

I need a help. datepickeris not working on laravel view file please help how to make it working

我需要帮助。datepicker不适用于 Laravel 视图文件,请帮助如何使其工作

For Live file, I have used this:

对于实时文件,我使用了这个:

{!! Html::script('http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css') !!}
{!! Html::script('https://code.jquery.com/ui/1.12.1/jquery-ui.js') !!}

<style>
    col-sm-2 control-label{
        text-align: left !important;
    }
</style>

and on input box I put id="datepicker"

在输入框上我放了 id="datepicker"

回答by Sagar Gautam

You have to put class="datepicker"in your input like this:

你必须class="datepicker"像这样输入你的输入:

<input class="form-control datepicker">

And you need to add some script as:

您需要添加一些脚本:

<script>
    jQuery(document).ready(function($) {
        $('.datepicker').datepicker({
            dateFormat: "yy-mm-dd"
        });
    });
</script>

UPDATE

更新

This is whole HTML page with necessary files.

这是包含必要文件的整个 HTML 页面。

<html lang="en">

<head>

    <title>Jquery - Datepicker Example using jquery ui</title>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script> 

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script> 

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

    <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.css" rel="stylesheet">   

</head>

<body>


<div class="container text-center">

     <h2>Jquery - Datepicker Example using jquery ui</h2>

     <strong>Select Date:</strong> <input type="text" id="datepicker" class="from-control">

</div>  


<script type="text/javascript">

    $( "#datepicker" ).datepicker();

</script>


</body>

</html>

Hope this might help you.

希望这可以帮助你。

回答by Nelson Katale

Add these lines of code in your app.blade.php

在 app.blade.php 中添加这些代码行

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

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

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

After that add dateas your input type in the blade.

之后date在刀片中添加为您的输入类型。

<input type="date" class="form-control" id="dob" name="dob">