mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 12:11:19 +00:00
add default values for jquery validation
This commit is contained in:
parent
cf411df04f
commit
3a3b4ec953
34
views/bootstrap/styles/validation-default.js
Normal file
34
views/bootstrap/styles/validation-default.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
jQuery.validator.setDefaults({
|
||||
errorElement: "em",
|
||||
errorClass: 'help-block',
|
||||
errorPlacement: function ( error, element ) {
|
||||
// Add the `error` class to the control-group
|
||||
$(element).closest('.control-group').addClass('error');
|
||||
if ( element.prop( "type" ) === "checkbox" ) {
|
||||
error.insertAfter( element.parent( "label" ) );
|
||||
} else {
|
||||
error.insertAfter( element );
|
||||
}
|
||||
|
||||
// Add the span element, if doesn't exists, and apply the icon classes to it.
|
||||
if ( !element.next( "span" )[ 0 ] ) {
|
||||
$( "<span class='glyphicon glyphicon-remove form-control-feedback'></span>" ).insertAfter( element );
|
||||
}
|
||||
},
|
||||
invalidHandler: function(e, validator) {
|
||||
noty({
|
||||
text: (validator.numberOfInvalids() == 1) ? trans.js_form_error.replace('#', validator.numberOfInvalids()) : trans.js_form_errors.replace('#', validator.numberOfInvalids()),
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
},
|
||||
highlight: function ( element, errorClass, validClass ) {
|
||||
$( element ).parents( ".control-group" ).addClass( "error" ).removeClass( "success" );
|
||||
},
|
||||
unhighlight: function ( element, errorClass, validClass ) {
|
||||
$( element ).parents( ".control-group" ).addClass( "success" ).removeClass( "error" );
|
||||
}
|
||||
});
|
33
views/bootstrap4/styles/validation-default.js
Normal file
33
views/bootstrap4/styles/validation-default.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
jQuery.validator.setDefaults({
|
||||
errorElement: 'div',
|
||||
errorClass: 'invalid-feedback',
|
||||
errorPlacement: function(error, element) {
|
||||
if(element.parent('.input-group').length) {
|
||||
error.insertAfter(element.parent());
|
||||
} else {
|
||||
error.insertAfter(element);
|
||||
}
|
||||
},
|
||||
invalidHandler: function(e, validator) {
|
||||
noty({
|
||||
text: (validator.numberOfInvalids() == 1) ? trans.js_form_error.replace('#', validator.numberOfInvalids()) : trans.js_form_errors.replace('#', validator.numberOfInvalids()),
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
timeout: 3500,
|
||||
});
|
||||
},
|
||||
highlight: function (element, errorClass, validClass) {
|
||||
if($(element).data('target-highlight'))
|
||||
$('#'+$(element).data('target-highlight')).addClass('is-invalid');
|
||||
else
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element, errorClass, validClass) {
|
||||
if($(element).data('target-highlight'))
|
||||
$('#'+$(element).data('target-highlight')).removeClass('is-invalid');
|
||||
else
|
||||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user