Chat Widget field Validation - white space

Hey team

I have configured the widget to do a validation on fields within the registration form. When entering single name/last name values, the validation works fine. But if the name or last name contains any white space, the validation fails to pass the validation process. Any idea how to handle entries with white space in it?

e.g. Name: John Paul - does not work as soon as a space is pressed between the names
e.g. Name: John - works fine and is valid.

Widget code is:

{
id: 'cx_webchat_form_firstname',
name: 'firstname',
maxlength: '100',
placeholder: 'Required',
label: 'First Name',
validateWhileTyping: true,
validate: function (event, form, input, label, $, CXBus, Common) {
if (input && input.val()) {
return true;
} else {
return false;
}
}
},

Hello,

Are you sure of your test?

I just tried the validate function on a Widgets v2.0 custom registration form and I don't have any problems between "John Paul" and "John".
Both work fine and are valid.

Regards,

Hi Jerome

Thanx for the update; I verified it again on the customer's website: https://kangan.edu.au/ and I get the same errors when using spaces. The email verification works and accepts valid emails as well as emails with spaces in them. It's only the first name/last name validation that keeps failing.

Hello,

The validate function (widget code) that you have shown in your first post is not what is configured on your kangan.edu.au site.

firstname and lastname fields are defined with:

validate: function(e, t, n, s, a, r, i) {
     return !!(n && n.val() && o.name.test(n.val()))
 },

with o.name.test being a regex test with rule /^\S*$/
And if you try this rule, you'll see it fails on validation when using a string with space(s) in it.

You just have to fix your Regex rule or use other javascript functions. I don't know what validation you are trying to perform on these fields. Check for empty string or string with spaces only?

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.