telegram_bots/static/js/examples/examples.validation.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-01-11 19:16:01 +00:00
(function() {
'use strict';
// basic
$("#form").validate({
highlight: function( label ) {
$(label).closest('.form-group').removeClass('has-success').addClass('has-error');
},
success: function( label ) {
$(label).closest('.form-group').removeClass('has-error');
label.remove();
},
errorPlacement: function( error, element ) {
var placement = element.closest('.input-group');
if (!placement.get(0)) {
placement = element;
}
if (error.text() !== '') {
placement.after(error);
}
}
});
// validation summary
var $summaryForm = $("#summary-form");
$summaryForm.validate({
errorContainer: $summaryForm.find( 'div.validation-message' ),
errorLabelContainer: $summaryForm.find( 'div.validation-message ul' ),
wrapper: "li"
});
// checkbox, radio and selects
$("#chk-radios-form, #selects-form").each(function() {
$(this).validate({
highlight: function(element) {
$(element).closest('.form-group').removeClass('has-success').addClass('has-error');
},
success: function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
errorPlacement: function( error, element ) {
var placement = $(element).parent();
placement.append(error);
}
});
});
// Select 2 Fields
$('select[data-plugin-selectTwo]').on('change', function() {
$(this).valid();
});
}).apply(this, [jQuery]);