Laravel 5验证日期为php Y格式。g 2015 ?
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.
和它的工作原理。
更多相关文章
- 提交动态复选框表单并成对获取值
- 仅在LARAVEL或AJAX中提交表单时,无需用户身份验证即可将文件上载
- 来自php表单的样式电子邮件
- 请问如何用php实现表单提交后以邮件的形式把表单内容发到邮箱中
- 如何在jQuery Mobile页面中提交表单?
- Symfony2 -从数据库中提取数据并以表单形式显示
- laravel 框架自带表单验证
- AJAX学习之提交表单
- 在提交注册表单时使用jQuery显示错误