I have a form that uses bootstraps datepicker. I want to collect the year as 2015 for example
我有一个使用bootstrap datepicker的表单。我想以2015年为例。
How do i do that?
我该怎么做呢?
The datepicker code is this:
datepicker代码是:
$('#manufacture_year').datepicker({
format: " yyyy",
viewMode: "years",
minViewMode: "years",
endDate: FromendDate,
autoclose: true,
disableEntry: true
});
I'm displaying the datepicker like so:
我这样显示datepicker:
{!! Form::text('manufacture_year', null, ['placeholder' => '1984', 'class' => 'form-control datepicker-default', 'id' => 'manufacture_year']) !!}
My validation rules are:
我的验证规则:
'manufacture_year' => 'required|date|date_format:Y'
When i submit the form i keep getting:
当我提交表单时,我一直得到:
The manufacture year is not a valid date.,The manufacture year does not match the format Y.
生产年份不是有效日期。,制作年份与格式Y不符。
I put 'Y' as the date format refering to:
我把“Y”作为日期格式,指的是:
http://php.net/manual/en/function.date.php
http://php.net/manual/en/function.date.php
Where it states that 'Y' equates a full numeric representation of a year, 4 digits
如果它说“Y”等于1年的完整数字表示,4位数
Thank you for reading this.
感谢您阅读本文。
1 个解决方案
#1
0
With @JoelHinz advice, i've changed my rules array to look like so
使用@JoelHinz建议,我已经将规则数组更改为这样。
'manufacture_year' => 'required|date_format:Y'
And it works.
和它的工作原理。
#1
0
With @JoelHinz advice, i've changed my rules array to look like so
使用@JoelHinz建议,我已经将规则数组更改为这样。
'manufacture_year' => 'required|date_format:Y'
And it works.
和它的工作原理。