How to fix JS to ignore spaces when checking for duplicates. | Community
Skip to main content
nowackem
New Participant
November 15, 2021
Solved

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

  • November 15, 2021
  • 1 reply
  • 697 views

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!

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mayank_Tiwari

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

 

1 reply

Mayank_Tiwari
Mayank_TiwariAccepted solution
Employee
November 17, 2021

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

 

nowackem
nowackemAuthor
New Participant
November 17, 2021

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