X-jo
X-jo

Reputation: 601

no space, no digit, one line validation?

<element name='description'>
 <display class='TextWdg'>
 <validation_js>return value.test(/^Client/)</validation_js>
 <validation_warning>It needs to start with Client</validation_warning> 
 </display>
</element>

this is an example that it starts with the word Client. [return value.test(/^Client/)] ie

Is there a way to add validation similarly so that it will not accept any spaces, no digits, no special characters, just letters(upper and lower)

Thanks

Upvotes: 1

Views: 101

Answers (1)

Faust
Faust

Reputation: 15394

/^[A-Za-z]*$/

That will allow only Latin characters (any number of them), from start to finish, and will accept an empty string. The beginning- and end-of-line delimeters (^ and $, respectively) require that the match be the only characters in the string you are checking.

To require at least one character, replace * with +

To specify the number if characters required more precisely, instead of the asterisk or plus, use

{x,y}

Where x and y are integers representing the min and max number of chars required.

More info on regular expressions can be found here: http://www.regular-expressions.info/

Upvotes: 3

Related Questions