first initial
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
// Class definition
|
||||
|
||||
var KTFormControls = function () {
|
||||
// Private functions
|
||||
|
||||
var demo1 = function () {
|
||||
$( "#kt_form_1" ).validate({
|
||||
// define validation rules
|
||||
rules: {
|
||||
email: {
|
||||
required: true,
|
||||
email: true,
|
||||
minlength: 10
|
||||
},
|
||||
url: {
|
||||
required: true
|
||||
},
|
||||
digits: {
|
||||
required: true,
|
||||
digits: true
|
||||
},
|
||||
creditcard: {
|
||||
required: true,
|
||||
creditcard: true
|
||||
},
|
||||
phone: {
|
||||
required: true,
|
||||
phoneUS: true
|
||||
},
|
||||
option: {
|
||||
required: true
|
||||
},
|
||||
options: {
|
||||
required: true,
|
||||
minlength: 2,
|
||||
maxlength: 4
|
||||
},
|
||||
memo: {
|
||||
required: true,
|
||||
minlength: 10,
|
||||
maxlength: 100
|
||||
},
|
||||
|
||||
checkbox: {
|
||||
required: true
|
||||
},
|
||||
checkboxes: {
|
||||
required: true,
|
||||
minlength: 1,
|
||||
maxlength: 2
|
||||
},
|
||||
radio: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
//display error alert on form submit
|
||||
invalidHandler: function(event, validator) {
|
||||
var alert = $('#kt_form_1_msg');
|
||||
alert.removeClass('kt--hide').show();
|
||||
KTUtil.scrollTop();
|
||||
},
|
||||
|
||||
submitHandler: function (form) {
|
||||
//form[0].submit(); // submit the form
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var demo2 = function () {
|
||||
$( "#kt_form_2" ).validate({
|
||||
// define validation rules
|
||||
rules: {
|
||||
//= Client Information(step 3)
|
||||
// Billing Information
|
||||
billing_card_name: {
|
||||
required: true
|
||||
},
|
||||
billing_card_number: {
|
||||
required: true,
|
||||
creditcard: true
|
||||
},
|
||||
billing_card_exp_month: {
|
||||
required: true
|
||||
},
|
||||
billing_card_exp_year: {
|
||||
required: true
|
||||
},
|
||||
billing_card_cvv: {
|
||||
required: true,
|
||||
minlength: 2,
|
||||
maxlength: 3
|
||||
},
|
||||
|
||||
// Billing Address
|
||||
billing_address_1: {
|
||||
required: true
|
||||
},
|
||||
billing_address_2: {
|
||||
|
||||
},
|
||||
billing_city: {
|
||||
required: true
|
||||
},
|
||||
billing_state: {
|
||||
required: true
|
||||
},
|
||||
billing_zip: {
|
||||
required: true,
|
||||
number: true
|
||||
},
|
||||
|
||||
billing_delivery: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
//display error alert on form submit
|
||||
invalidHandler: function(event, validator) {
|
||||
swal.fire({
|
||||
"title": "",
|
||||
"text": "There are some errors in your submission. Please correct them.",
|
||||
"type": "error",
|
||||
"confirmButtonClass": "btn btn-secondary",
|
||||
"onClose": function(e) {
|
||||
console.log('on close event fired!');
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
},
|
||||
|
||||
submitHandler: function (form) {
|
||||
//form[0].submit(); // submit the form
|
||||
swal.fire({
|
||||
"title": "",
|
||||
"text": "Form validation passed. All good!",
|
||||
"type": "success",
|
||||
"confirmButtonClass": "btn btn-secondary"
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// public functions
|
||||
init: function() {
|
||||
demo1();
|
||||
demo2();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
KTFormControls.init();
|
||||
});
|
||||
1
public/assets/js/demo1/pages/crud/forms/validation/form-controls.min.js
vendored
Normal file
1
public/assets/js/demo1/pages/crud/forms/validation/form-controls.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var KTFormControls={init:function(){$("#kt_form_1").validate({rules:{email:{required:!0,email:!0,minlength:10},url:{required:!0},digits:{required:!0,digits:!0},creditcard:{required:!0,creditcard:!0},phone:{required:!0,phoneUS:!0},option:{required:!0},options:{required:!0,minlength:2,maxlength:4},memo:{required:!0,minlength:10,maxlength:100},checkbox:{required:!0},checkboxes:{required:!0,minlength:1,maxlength:2},radio:{required:!0}},invalidHandler:function(e,r){$("#kt_form_1_msg").removeClass("kt--hide").show(),KTUtil.scrollTop()},submitHandler:function(e){}}),$("#kt_form_2").validate({rules:{billing_card_name:{required:!0},billing_card_number:{required:!0,creditcard:!0},billing_card_exp_month:{required:!0},billing_card_exp_year:{required:!0},billing_card_cvv:{required:!0,minlength:2,maxlength:3},billing_address_1:{required:!0},billing_address_2:{},billing_city:{required:!0},billing_state:{required:!0},billing_zip:{required:!0,number:!0},billing_delivery:{required:!0}},invalidHandler:function(e,r){swal.fire({title:"",text:"There are some errors in your submission. Please correct them.",type:"error",confirmButtonClass:"btn btn-secondary",onClose:function(e){console.log("on close event fired!")}}),e.preventDefault()},submitHandler:function(e){return swal.fire({title:"",text:"Form validation passed. All good!",type:"success",confirmButtonClass:"btn btn-secondary"}),!1}})}};jQuery(document).ready(function(){KTFormControls.init()});
|
||||
@@ -0,0 +1,147 @@
|
||||
// Class definition
|
||||
|
||||
var KTFormWidgets = function () {
|
||||
// Private functions
|
||||
var validator;
|
||||
|
||||
var initWidgets = function() {
|
||||
// datepicker
|
||||
$('#kt_datepicker').datepicker({
|
||||
todayHighlight: true,
|
||||
templates: {
|
||||
leftArrow: '<i class="la la-angle-left"></i>',
|
||||
rightArrow: '<i class="la la-angle-right"></i>'
|
||||
}
|
||||
});
|
||||
|
||||
// datetimepicker
|
||||
$('#kt_datetimepicker').datetimepicker({
|
||||
pickerPosition: 'bottom-left',
|
||||
todayHighlight: true,
|
||||
autoclose: true,
|
||||
format: 'yyyy.mm.dd hh:ii'
|
||||
});
|
||||
|
||||
$('#kt_datetimepicker').change(function() {
|
||||
validator.element($(this));
|
||||
});
|
||||
|
||||
// timepicker
|
||||
$('#kt_timepicker').timepicker({
|
||||
minuteStep: 1,
|
||||
showSeconds: true,
|
||||
showMeridian: true
|
||||
});
|
||||
|
||||
// daterangepicker
|
||||
$('#kt_daterangepicker').daterangepicker({
|
||||
buttonClasses: ' btn',
|
||||
applyClass: 'btn-primary',
|
||||
cancelClass: 'btn-secondary'
|
||||
}, function(start, end, label) {
|
||||
var input = $('#kt_daterangepicker').find('.form-control');
|
||||
|
||||
input.val( start.format('YYYY/MM/DD') + ' / ' + end.format('YYYY/MM/DD'));
|
||||
validator.element(input); // validate element
|
||||
});
|
||||
|
||||
// bootstrap switch
|
||||
$('[data-switch=true]').bootstrapSwitch();
|
||||
$('[data-switch=true]').on('switchChange.bootstrapSwitch', function() {
|
||||
validator.element($(this)); // validate element
|
||||
});
|
||||
|
||||
// bootstrap select
|
||||
$('#kt_bootstrap_select').selectpicker();
|
||||
$('#kt_bootstrap_select').on('changed.bs.select', function() {
|
||||
validator.element($(this)); // validate element
|
||||
});
|
||||
|
||||
// select2
|
||||
$('#kt_select2').select2({
|
||||
placeholder: "Select a state",
|
||||
});
|
||||
$('#kt_select2').on('select2:change', function(){
|
||||
validator.element($(this)); // validate element
|
||||
});
|
||||
|
||||
// typeahead
|
||||
var countries = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
prefetch: 'https://keenthemes.com/metronic/themes/themes/metronic/dist/preview/inc/api/typeahead/countries.json'
|
||||
});
|
||||
|
||||
$('#kt_typeahead').typeahead(null, {
|
||||
name: 'countries',
|
||||
source: countries
|
||||
});
|
||||
$('#kt_typeahead').bind('typeahead:select', function(ev, suggestion) {
|
||||
validator.element($('#kt_typeahead')); // validate element
|
||||
});
|
||||
}
|
||||
|
||||
var initValidation = function () {
|
||||
validator = $( "#kt_form_1" ).validate({
|
||||
// define validation rules
|
||||
rules: {
|
||||
date: {
|
||||
required: true,
|
||||
date: true
|
||||
},
|
||||
daterange: {
|
||||
required: true
|
||||
},
|
||||
datetime: {
|
||||
required: true
|
||||
},
|
||||
time: {
|
||||
required: true
|
||||
},
|
||||
|
||||
select: {
|
||||
required: true,
|
||||
minlength: 2,
|
||||
maxlength: 4
|
||||
},
|
||||
select2: {
|
||||
required: true
|
||||
},
|
||||
typeahead: {
|
||||
required: true
|
||||
},
|
||||
|
||||
switch: {
|
||||
required: true
|
||||
},
|
||||
|
||||
markdown: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
//display error alert on form submit
|
||||
invalidHandler: function(event, validator) {
|
||||
var alert = $('#kt_form_1_msg');
|
||||
alert.removeClass('kt--hide').show();
|
||||
KTUtil.scrollTo('m_form_1_msg', -200);
|
||||
},
|
||||
|
||||
submitHandler: function (form) {
|
||||
//form[0].submit(); // submit the form
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// public functions
|
||||
init: function() {
|
||||
initWidgets();
|
||||
initValidation();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
KTFormWidgets.init();
|
||||
});
|
||||
1
public/assets/js/demo1/pages/crud/forms/validation/form-widgets.min.js
vendored
Normal file
1
public/assets/js/demo1/pages/crud/forms/validation/form-widgets.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var KTFormWidgets=function(){var e;return{init:function(){!function(){$("#kt_datepicker").datepicker({todayHighlight:!0,templates:{leftArrow:'<i class="la la-angle-left"></i>',rightArrow:'<i class="la la-angle-right"></i>'}}),$("#kt_datetimepicker").datetimepicker({pickerPosition:"bottom-left",todayHighlight:!0,autoclose:!0,format:"yyyy.mm.dd hh:ii"}),$("#kt_datetimepicker").change(function(){e.element($(this))}),$("#kt_timepicker").timepicker({minuteStep:1,showSeconds:!0,showMeridian:!0}),$("#kt_daterangepicker").daterangepicker({buttonClasses:" btn",applyClass:"btn-primary",cancelClass:"btn-secondary"},function(t,i,a){var r=$("#kt_daterangepicker").find(".form-control");r.val(t.format("YYYY/MM/DD")+" / "+i.format("YYYY/MM/DD")),e.element(r)}),$("[data-switch=true]").bootstrapSwitch(),$("[data-switch=true]").on("switchChange.bootstrapSwitch",function(){e.element($(this))}),$("#kt_bootstrap_select").selectpicker(),$("#kt_bootstrap_select").on("changed.bs.select",function(){e.element($(this))}),$("#kt_select2").select2({placeholder:"Select a state"}),$("#kt_select2").on("select2:change",function(){e.element($(this))});var t=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.whitespace,queryTokenizer:Bloodhound.tokenizers.whitespace,prefetch:"https://keenthemes.com/metronic/themes/themes/metronic/dist/preview/inc/api/typeahead/countries.json"});$("#kt_typeahead").typeahead(null,{name:"countries",source:t}),$("#kt_typeahead").bind("typeahead:select",function(t,i){e.element($("#kt_typeahead"))})}(),e=$("#kt_form_1").validate({rules:{date:{required:!0,date:!0},daterange:{required:!0},datetime:{required:!0},time:{required:!0},select:{required:!0,minlength:2,maxlength:4},select2:{required:!0},typeahead:{required:!0},switch:{required:!0},markdown:{required:!0}},invalidHandler:function(e,t){$("#kt_form_1_msg").removeClass("kt--hide").show(),KTUtil.scrollTo("m_form_1_msg",-200)},submitHandler:function(e){}})}}}();jQuery(document).ready(function(){KTFormWidgets.init()});
|
||||
Reference in New Issue
Block a user