These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Prevent entry of a space into a Text Field

AcrUmbi
Registered: Dec 2 2010
Posts: 18
Answered

Hello,
 
As indicated above, I have a Text field that is meant to hold a first name. How can I prevent entry of a space? Can this be done only via JavaScript or is it possible via an Edit pattern?
 
Along the same lines, is there an easy way to force the data entry to immediately be uppercased? I'm not talking about some JavaScript on the field's exit event...and I've tried attaching said code to the change event with no success. My understanding is that the change event would be triggered every time the user types in one letter?
 
Thank you!
Her

My Product Information:
LiveCycle Designer, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
For #1, what about people with two (or more) first names? Bobby Joe, Mary Margaret, Anne Marie, Juan Carlos, etc.

For #2, what code have you tried?
AcrUmbi
Registered: Dec 2 2010
Posts: 18
I agree with you George, yet this was a client/customer request. Odd, I know.

Regarding upperCasing, I have used JavaScript attached to the Exit and/or Change event of the field, something like

this.rawValue = this.rawValue.toUpperCase();

But again, I was expecting this code to be fired/executed (when attached to the Change event) in real time, i.e. as the user is typing in the data and that wasn't happening and that is exactly what I want. I want that regardless of the user's keyboard being in "lowercase" mode, that when he/she types for example the 'a' character...the entry is immediately uppercased to 'A'.

Regards,
Her
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
For #2, in a change event script, try:

xfa.event.change = xfa.event.change.toUpperCase();

This should give you a hint for #1.
AcrUmbi
Registered: Dec 2 2010
Posts: 18
Aaaah, sweet!

You stud George! Yes, that worked...for #2 at least, will try for stripping out space characters. This is a form design that I've inherited so pardon my ignorance. I am trying to find ways to improve it and also make it more OCR friendly since these forms get scanned in.

Thank you for your knowledge sharing..but I am still curious...is there a way to do these things NOT via JavaScript? Say via the Edit/Validation/Display patterns?

Again, thanks.
Her