The script bellow changes the value of "form-field-conversion" (hidden field) from 'ok' to 'nok', if any of the "Const Words" is present in the "form-field-message".
The problem with this code is that it only detects each word as it is, with no variation.
I need help to make this code accept capital letters and special carachters. Instead of writting "currículo", "curriculo", "Currículo", I want to write only "curriculo" and cover all variantions (like Currículo, CURRÍculo, CURRICULO, currículo, ...).
Can you help me?
<script>
new BulldeskIntegration({
token: '123456',
map: {
'form_fields[identifier]': 'identifier',
'form_fields[name]': 'name',
'form_fields[email]': 'email',
'form_fields[phone]': 'phone',
'form_fields[message]': 'message',
},
mapCallback: function (fields) {
const words = [
'curriculo',
'currículo',
'Curriculo',
'Currículo',
'CURRÍCULO',
'CURRICULO',
];
const {
value,
} = document.querySelector('#form-field-message');
if (value && new RegExp(words.join("|")).test(value)) {
jQuery('#form-field-conversion').attr('value', 'nok');
return [];
}
return fields;
}
});
</script>