javascript - 日期 不专门在 laravel 中工作

标签 javascript php mysql laravel date

我现在正在做一个项目。在这个项目中,我陷入了困境。我的项目遇到了问题。在我的项目中,用户可以添加、编辑或更新他的体验。为此我需要日期。用户可以添加他迄今为止的工作经验。但在这里我无法选择前一个日期。我只能选择从今天到 future 的一天,但无法选择之前的日期。我不明白问题出在哪里。 我的代码如下

<h3 class="margin-bottom-20">Work Experience</h3>
<h4>Please list experience in chronological order, with most recent experience first.</h4><br>
<div class="margin-bottom-30">
    <a href="#" data-toggle="modal" data-target="#addWorkExperience"
       class="btn color-2 size-2 hover-1"><i class="fa fa-plus"></i> Add Work
        Experience</a>
    <div class="resume">
        @if (isset($user_work_experiences))
            @foreach ($user_work_experiences as $user_work_experience)
                <div class="resume-list">
                    <div class="meta-header">
                        <p>{{ (!empty($user_work_experience->from_date)) ? $user_work_experience->from_date : '' }}
                            <i>to</i> {{ $user_work_experience->to_date }}</p>
                    </div>

                </div>
            @endforeach
        @endif
    </div>
</div>

点击按钮后,这将起作用

    <div class="modal fade" id="addWorkExperience" tabindex="-1" role="dialog" aria-labelledby="addExperience">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Add Experience</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group focus-2">
                            <div class="form-label">From Date</div>
                            <input class="form-input datepicker" id="job_from_date" onblur="job_from_date()" onkeypress="job_from_date()" name="job_from_date" type="text" value="" placeholder="MM/DD/YYYY">
                            <label id="error_job_from_date" style="color:red"></label>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group focus-2">
                            <div class="form-label">To Date</div>
                            <input class="form-input datepicker" id="job_to_date" onblur="job_to_date()" onkeypress="job_to_date()" name="job_to_date" type="text" value=""
                                   placeholder="MM/DD/YYYY">
                            <div class="be-checkbox">
                                <label class="check-box">
                                    <input type="checkbox" name="job_current_date" id="job_current_date" onblur="job_current_date()" onkeypress="job_current_date()" value="{{ \Carbon\Carbon::now()->format('m/d/Y') }}" class="checkbox-input">
                                    <span class="check-box-sign"></span>
                                </label>
                                <span class="large-popup-text"> Currently Work Here </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-lg btn-default" data-dismiss="modal">
                    Close
                </button>
                <button type="button" onclick="add_job_experience()"
                        class="be-popup-sign-button">Add Experience
                </button>
            </div>
        </div>
    </div>
</div>

我的Javascript代码是

function add_job_experience() {
if (job_title() && company_name() && job_from_date() && (job_to_date() || job_current_date()) && job_description()) {
    $.ajax(
            {
                type: 'POST',
                url: '{{ URL::to('profile/edit/work/experience') }}',
                data: {
                    'job_title': document.getElementById('job_title').value,
                    'company_name': document.getElementById('company_name').value,
                    'from_date': document.getElementById('job_from_date').value,
                    'to_date': document.getElementById('job_to_date').value,
                    'current_date': document.getElementById('job_current_date').value,
                    'description': document.getElementById('job_description').value
                },
                cache: false,
                success: function (result) {
                    if (result == 1) {
                        alert('work experience add successful');
                        window.location.reload();
                    } else {
                        alert(result);
                    }
                }
            }
    )
} else {
}
}

请帮我解决这个问题。

最佳答案

这只需在 JavaScript 中添加即可完成

jQuery('.datepicker').datetimepicker({
        timepicker:false,
        format:'m-d-Y'
    });

关于javascript - 日期 不专门在 laravel 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40355467/

相关文章:

javascript - 获取此 DIV 的父 ID

Javascript getFullYear、getMonth、getDate 不起作用

php - 通过 PHP 连接到数据库不起作用

php - 尝试在使用回显行时将发送者和接收者与内部联合表分开

php - 如何在redbean php中使用id更新特定行

Javascript展开数组/更改数据结构

javascript - JS如何通过模板文字中的Array进行映射

php - 使用 preg_replace 替换无效字符

mysql - mysql root 用户是否总是默认具有所有权限?

php - SQLite 与 MySQL ->rowCount()