// Validation Rules
validator = FormValidation.formValidation(
document.getElementById('kt_form'),
{
fields: {
date: {
validators: {
notEmpty: {
message: 'تاریخ is required'
}
}
},
daterangepicker: {
validators: {
notEmpty: {
message: 'تاریخrange is required'
}
}
},
datetime: {
validators: {
notEmpty: {
message: 'تاریخtime is required'
}
}
},
time: {
validators: {
notEmpty: {
message: 'زمان is required'
}
}
},
select: {
validators: {
notEmpty: {
message: 'انتخاب is required'
}
}
},
select2: {
validators: {
notEmpty: {
message: 'انتخابگر2 is required'
}
}
},
typeahead: {
validators: {
notEmpty: {
message: 'تایپ هد is required'
}
}
},
switch: {
validators: {
notEmpty: {
message: 'تایپ هد is required'
}
}
},
markdown: {
validators: {
notEmpty: {
message: 'تایپ هد is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
submitدکمه: new FormValidation.plugins.ارسالدکمه(),
bootstrap: new FormValidation.plugins.بوت استرپ({
eleInvalidکلاس: '',
eleValidکلاس: '',
})
}
}
);
// Initialize Plugins
// انتخابگر تاریخ
دلار('#kt_datepicker').datepicker({
todayسلامghlight: true,
templates: {
leftArrow: '<i class="la la-angle-left"></i>',
rightArrow: '<i class="la la-angle-right"></i>'
}
}).on('changeتاریخ', function(e) {
// Revalidate field
validator.revalidateField('date');
});
// انتخابگر تاریخ و زمان
دلار('#kt_datetimepicker').datetimepicker({
pickerPosition: 'bottom-left',
todayسلامghlight: true,
autoclose: true,
format: 'yyyy.mm.dd hh:ii'
});
دلار('#kt_datetimepicker').change(function() {
// Revalidate field
validator.revalidateField('datetime');
});
// انتخاب گر زمان
دلار('#kt_timepicker').timepicker({
minuteگام: 1,
showSeconds: true,
showMeridian: true
});
دلار('#kt_timepicker').change(function() {
// Revalidate field
validator.revalidateField('time');
});
// انتخابگر رنج تاریخ
دلار('#kt_daterangepicker').daterangepicker({
buttonکلاسes: ' btn',
applyکلاس: 'btn-primary',
cancelکلاس: 'btn-light-primary'
}, function(start, end, label) {
var input = دلار('#kt_daterangepicker').find('.form-control');
input.val( start.format('YYYY/MM/DD') + ' / ' + end.format('YYYY/MM/DD'));
// Revalidate field
validator.revalidateField('daterangepicker');
});
// بوت استرپ سوئیچ
دلار('[data-switch=true]').bootstrapسوئیچ();
دلار('[data-switch=true]').on('switchChange.bootstrapسوئیچ', function() {
// Revalidate field
validator.revalidateField('switch');
});
// انتخابگر بوت استرپ
دلار('#kt_bootstrap_select').selectpicker();
دلار('#kt_bootstrap_select').on('changed.bs.select', function() {
// Revalidate field
validator.revalidateField('select');
});
// انتخابگر2
دلار('#kt_select2').select2({
placeholder: "انتخاب a state",
});
دلار('#kt_select2').on('change', function(){
// Revalidate field
validator.revalidateField('select2');
});
// تایپ هد
var countries = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: HOST_URL + '/api/?file=typeahead/countries.json'
});
دلار('#kt_typeahead').typeahead(null, {
name: 'countries',
source: countries
});
دلار('#kt_typeahead').bind('typeahead:select', function(ev, suggestion) {
// Revalidate field
validator.revalidateField('typeahead');
});