Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Do not allow spacing in a text field

Avatar

Level 2

I have a form where the data will be imported into a database, so we don't want the users to be able to allow spacing when they enter the data.  Is there a way to do this?

Thanks, Anne

5 Replies

Avatar

Level 4

Use below script

TextField2.rawValue = this.rawValue.replace(/\s\s+/gm,"");


Hope this helps

Vipin

Avatar

Level 2

thanks.  I put the script in "validate" and it won't allow me to enter anything.  Should I be putting it somewhere else?

SampleRef.rawValue = this.rawValue.replace(/\s\s+/gm,"");

Avatar

Level 4

I have uploaded the file where i have created 2 textfield. If you enter some text in textfield1 that contains space, it will display the same text in textfield2 without spaces. 

https://workspaces.acrobat.com/?d=rqxwyQuc7qBv9iq-NPAk4Q

Avatar

Level 10

You can Filter the User Input while typing and delete spaces directly.

Add this Script to the change Event of a field.

xfa.event.change = xfa.event.change.replace(/\s/g, "");

Avatar

Level 2

This worked perfectly.  Thank you so much!