* fix possibility to have empty name/surname and empty company Signed-off-by: Michael Kaufmann <d00p@froxlor.org> * let js validation for customer add/edit form also trim() entered data to avoid empty values pass the client-side validation Signed-off-by: Michael Kaufmann <d00p@froxlor.org> --------- Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
43 lines
961 B
JavaScript
43 lines
961 B
JavaScript
export default function () {
|
|
$(function () {
|
|
/*
|
|
* validation
|
|
*/
|
|
$('#customer_add,#customer_edit').each(function () {
|
|
$(this).validate({
|
|
rules: {
|
|
'name': {
|
|
required: function () {
|
|
return $('#company').val().trim().length === 0 || $('#firstname').val().trim().length > 0;
|
|
}
|
|
},
|
|
'firstname': {
|
|
required: function () {
|
|
return $('#company').val().trim().length === 0 || $('#name').val().trim().length > 0;
|
|
}
|
|
},
|
|
'company': {
|
|
required: function () {
|
|
return $('#name').val().trim().length === 0
|
|
&& $('#firstname').val().trim().length === 0;
|
|
}
|
|
}
|
|
},
|
|
});
|
|
});
|
|
$('#domain_add,#domain_edit').each(function () {
|
|
$(this).validate({
|
|
rules: {
|
|
'ipandport[]': {
|
|
required: true,
|
|
minlength: 1
|
|
}
|
|
},
|
|
errorPlacement: function (error, element) {
|
|
$(error).prependTo($(element).parent().parent());
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|