For example the field to be only 3 digit/letters only or make the text all capital letters, is this possible ?
If the input is not free text, the best way is to use a dropdown list. but if it’s free text, you can use a script to manage the input from the user.
<script>
document.addEventListener('DOMContentLoaded', () => {
const labelText = 'Test Input Box';
const labels = document.querySelectorAll('label');
labels.forEach(label => {
if (label.textContent.trim() === labelText) {
const formGroup = label.closest('.form-group');
if (formGroup) {
const input = formGroup.querySelector('input');
if (input) {
input.addEventListener('input', function (e) {
e.target.value = e.target.value.replace(/[^A-Z0-9]/g, '');
if (e.target.value.length > 3) {
e.target.value = e.target.value.substring(0, 3);
}
});
}
}
}
});
});
</script>
2 Likes
I can work around this, thank you.
@Mabaega I moved the custom field to purchase invoice - line to show beside the description, but the formatting doesn’t work, i am not sure if it is a problem with the placement and can be fixed in the script or it is not possible. Appreciate your help.
The script cannot work at line level.
It’s very difficult to make this work at line level because Custom Fields don’t have ids.
If possible, you should use Custom Fields with a Dropdown List so that users can choose from the available list.
2 Likes