Expand my Community achievements bar.

SOLVED

How to fix JS to ignore spaces when checking for duplicates.

Avatar

Level 6

I have a form that checks for duplicate names (these are first and last names within one field) but I would like the script to ignore any spaces at the end or before the text (but not if there is a space between words) no matter how many words are in the field. For example, the current script would not catch Firstname Lastname(space) being the same as Firstname Lastname(no space) hence no duplicates detected. Anyone know how to update this? I seem to break it every time I try. The form is located here: https://drive.google.com/drive/folders/1gneWXGTgzvCEeZHBxumR3v429X6nBzbJ?usp=sharing

Thank you!

 

1 Accepted Solution

Avatar

Correct answer by
Employee
2 Replies

Avatar

Correct answer by
Employee

You may use Trim[0] method to remove the leading and trailing spaces from the textValue.

 

Fixed Form: https://drive.google.com/file/d/1WT1OHXjSgVky9RgEmyDf539iPRRqtsti/view?usp=sharing

 

[0]: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_trim

 

Avatar

Level 6

Thank you for the solution and the reference! I appreciate it.