Highlighted

Ensure input is all alpha characters?

BJeppson

29-06-2008

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

Replies

Highlighted

pguerett

30-06-2008

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().
Highlighted

Avatar

Guest

23-09-2008

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
Highlighted

pguerett

23-09-2008

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.
Highlighted

Avatar

Guest

23-09-2008

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
Highlighted

Avatar

Guest

23-09-2008

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
Highlighted

Avatar

Guest

26-09-2008

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