Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Format text field to alpha only

New Here ,
Nov 24, 2017 Nov 24, 2017

Anyone have insight on the custom format script for creating text fields with alpha only input?

TOPICS
PDF forms
5.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Nov 24, 2017 Nov 24, 2017

You can use this code as the custom Keystroke script:

if (event.change) event.rc = /^[a-z]+$/i.test(event.change);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 24, 2017 Nov 24, 2017

You can use this code as the custom Keystroke script:

if (event.change) event.rc = /^[a-z]+$/i.test(event.change);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 05, 2018 Sep 05, 2018

I have a field - Case Name, and I used the coding above - if (event.change) event.rc = /^[a-z]+$/i.test(event.change); - and yes I can only type alpha characters in it, which is great but I cannot put a space between the first and last name.

Example: Jane Doe becomes JaneDoe

Is there a way to allow spaces?

Thank you,

Jamie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2018 Sep 05, 2018

Simply add a space character inside the square brackets.

However, names can contain all kinds of characters, beside letters and spaces. What about hyphens? Apostrophes? Periods?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2018 Sep 05, 2018

Do not forget capitol letters.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2018 Sep 05, 2018

Capital letters are already allowed by the script above, because of the "i" flag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 05, 2018 Sep 05, 2018

Hmm, I didn't think of those scenarios.

Can you direct me to maybe a pdf document or some source where I could find coding for spaces, hyphens and such.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2018 Sep 05, 2018

Basically, you should insert all the characters you want to allow into the square brackets.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 06, 2018 Sep 06, 2018

Got it, but how do I find out what represents the characters like for a space?  Can you direct me to where I can go to look these items up?

Where I can find out what the coding that you provided is actually doing and what the symbols mean (bolded text below)?

if (event.change) event.rc = /^[a-z]+$/i.test(event.change);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 06, 2018 Sep 06, 2018

See Special characters meaning in regular expressions

Then scroll down to "Character Classes"

\s  Matches a single white space character, including space, tab, form feed, line feed and other Unicode spaces. Equivalent to [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].

\tMatches a horizontal tab.
\rMatches a carriage return.
\nMatches a linefeed.
\vMatches a vertical tab.
\fMatches a form-feed.
[\b]Matches a backspace. (Not to be confused with \b)
\0Matches a NUL character. Do not follow this with another digit.
\cX

Where X is a letter from A - Z. Matches a control character in a string.

if (event.change) event.rc = /^[a-zA-Z\s]+$/.test(event.change);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 06, 2018 Sep 06, 2018
LATEST

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines