这是我的bootstrap multiselect,工作正常
<div class="col-12 col-sm-6 col-md-6 col-lg-4">
<div class="form-group">
<p>Required Skills<span class="notice-txt">*</span></p>
<select class="multisel form-control" data="createNew" name="requiredskills[]" multiple="multiple">
@foreach($skills as $sk)
<option @if( !empty($JobOrderSkills) and isset($JobOrderSkills[$sk['skillid']]) and $JobOrderSkills[$sk['skillid']]['skillid'] == $sk['skillid']) selected @endif value="{{$sk['skillkey']}}">{{$sk['skill']}}</option>
@endforeach
</select>
</div>
</div>
我在单个选择字段中使用相同的多选类,但它没有显示jquery验证消息
<div class="col-12 col-sm-6 col-md-6 col-lg-4">
<div class="form-group">
<p>Status<span class="notice-txt">*</span></p>
<select class="form-control validrmvcls multisel" name="joborderstatus">
<option value="">--Select--</option>
@foreach($joborderStatus as $jos)
<option @if( !empty($row) && $jos['joborder_status_id'] == $row['joborder_status_id'] ) selected @endif value="{{$jos['joborder_status_key']}}">{{$jos['joborder_status']}}</option>
@endforeach
</select>
</div>
</div>
这是我的jquery验证
$(document).ready(function () {
multipleSelect();
$('#createNew').validate({
ignore :[],
rules : {
joborderstatus: 'required',
'requiredskills[]' : 'required'
},
messages : {
joborderstatus :'Please select Status',
'requiredskills[]' :'Please select Required Skills'
},
errorPlacement: function(error, element) {
if( element.hasClass("validrmvcls")) {
error.insertAfter( element.parent("div") );
}else if (element.hasClass('multisel')) {
error.insertAfter(element.next('div'));
}else{
error.insertAfter(element);
}
}
});
多重选择
function multipleSelect() {
$('.multisel').multiselect({
enableFiltering: true,
filterPlaceholder: 'Search',
enableCaseInsensitiveFiltering : true,
includeSelectAllOption: true,
onChange: function(element, checked) {
$(element).valid();
//var id = $('.multisel').attr('data');
//$("#"+id).valid();
}
});
}
请提前协助我并提前致谢
答案 0 :(得分:0)
将ID createNew用于您的选择字段
$('#createNew')。validate({
$('#createNew')在您的代码中找到ID,但找不到。
使用ID验证功能