我正在使用proengsoft/laravel-jsvalidation来验证我的自定义表单请求,但它不适用于我,它提供ReferenceError: jQuery is not defined
。即使在其文档中也搜索了很多关于这个问题但却找不到的问题。任何帮助表示赞赏。
//app view
@include('partials.nav')
@include('errors.errors')
@yield('content')
<!-- Scripts -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
<!-- Laravel Javascript Validation -->
<script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
我要验证的表格
//Upload Form
{!! Form::model($paper, ['method' => 'POST', 'id' =>'uploadPaper', 'action' => ['PaperController@papershow', $paper->id], 'files' => true]) !!}
@include('partials._paperForm',['submitBtn' => 'Show Paper Details'])
{!! Form::close() !!}
<!-- Laravel Javascript Validation -->
{!! JsValidator::formRequest('App\Http\Requests\PaperRequest'); !!}
我的自定义请求:
//App\Http\Requests\PaperRequest
public function rules()
{
return [ 'title'=> 'required|min:10',
'type' => 'required',
'keywords'=> 'required|min:10',
'abstract'=> 'required|min:50',
'dept_name' => 'required|min:3',
'file' => 'required|mimes:pdf|max:10000',];}
答案 0 :(得分:2)
确保在加载依赖于它的validation.js
之前加载jQuery。
来自docs:
这个包也依赖于jQuery,但它没有捆绑到 提供脚本,您必须手动包含
要使用此软件包,您可以在提供之前使用jQuery public / vendor / jsvalidation / js / jsvalidation.js script
https://github.com/proengsoft/laravel-jsvalidation/wiki/Dependencies