Files
Froxlor/templates/Froxlor/assets/js/jquery/validation.js
Michael Kaufmann 4b1846883d Merge pull request from GHSA-625g-fm5w-w7w4
* 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>
2023-12-15 09:36:06 +01:00

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());
}
});
});
});
}