Skip to main content
Known Participant
March 9, 2022
Question

REMOVE BLANKS/WHITESPACE Before and after Fillable form field Name/Text entry

  • March 9, 2022
  • 1 reply
  • 1313 views

Hi, I need a quick JavaScript that will take a form field entery (say First_Name) and remove any whitespace or blanks that the end-user might have entered before and after whatever was typed.

 

Also, where to put that script in the field?  There is already some validation going on that is working, but I'm uncertain is this would ba a custom "Action" or custom "Format". 

 

Basically, I want whatever text the user types into the form field to be stripped of whitespace (except for spaces between say the first and middle name) and then left-justified

 

Thanks!

This topic has been closed for replies.

1 reply

BarlaeDC
Community Expert
Community Expert
March 11, 2022

Hi,

 

In the validation tab,  add this to your script

event.value = event.value.trim();

 

you could also assign it to a variable if you are doing more work on it

 

var trimmedString = event.value.trim();

// other code goes here

event.value = trimmedString

edm1965Author
Known Participant
March 11, 2022

Yep. That did it. Thanks!   

 

I'm going to start another thread regarding the clear form/reset for button I've implemented.