Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Ensure input is all alpha characters?

BJeppson
Level 2
Level 2
My form has some fields that should only have alphbetic characters--no numbers or symbols--but the lengths will vary from a couple of letters to an entire sentence. For example, entering a bunch of cities and counties and peoples' names. The length varies, but all must be alpha characters only.



Thanks.



Buck
7 Replies
pguerett
Level 10
Level 10
On the exit event of the field you want to effect you can run a javascript command to force th etyped in input to Upper case. I believe the command is toUpper().
Not applicable
Hi Paul,



Can u explain the same.

I have taken text field;it takes numerics,symbols as well as alphabets.

How can we validate that the field consists of alphabet only? How the scripting can be done?



i didnt get the use of toupper(),how it will ensure the field consists of only alpha characters.



Thanks



Buddy
pguerett
Level 10
Level 10
The toUpper() is a javascript command that can be applied to a string that woudl return all chars in upper case. If you want to restrict to alpha only then having a mask of text{AAAA} forces a 4 char alpha input. If the number of chars is unknown then you will have to test each char as it is entered. I have script somewhere for this so if you need it let me know.
Not applicable
Hi Paul,



The number of characters is unknown,i need to validate fields like customer name.

I have tried with text{AAA}.But it works only for word length of 3.I need to check for variable length field. Please provide me with the Script.It will be a great help.



Thanks,

Buddy
Not applicable
Hi Paul,

I have one more question.

For better Performance which one is better for a large sized file

1)validation

2)scripting



For variable length character validation is Scripting the only option?



Thanks,

Buddy
pguerett
Level 10
Level 10
If you do not know the length the scripting is your only choice.
Not applicable
You could use a regular expression in the exit event (using JavaScript). The following will return true if the user has entered any combination of spaces and letters (including an entry consisting of all spaces - you may want to handle that scenario as well):



if (!this.rawValue.match(/^[\sA-Za-z]+$/)){

// Handle the error as desired here

}



To learn more about RegExp, check out this tutorial:

http://www.regular-expressions.info/tutorial.html