How to allow spaces in the validate-alpha?

others 23 Jul, 2008
Hello,
I would like to know how can i allow spaces in the alpha validation?
Beacuse I have some text with spaces.

Thank you,

Regards,
GreyHead 24 Jul, 2008
Hi others,

You'll need to hack the validation JavaScript for this. In MooValidation.js around line 197* you'll find a snippet of RegExp like this /^[a-zA-Z]+$/. You can either hack this to allow spaces - Beware this will affect all alpha validation on your site; or, you can add a custom validation - Instructions for this are on Andrew Tetlaw's Dexagogo site (look for Really Easy Validation).

Bob

If you are using the Prototype library you'll need to look in validation.js instead.
others 31 Jul, 2008
Hello Bob,

Worked!

Thank you for your support!!


Regards
blindman 22 Oct, 2008
So, is this the expression?

/^[a-zA-Z]+\s+$/

Before
['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
return Validation.get('IsEmpty').test(v) || /^[a-zA-Z]+$/.test(v)

After
['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
return Validation.get('IsEmpty').test(v) || /^[a-zA-Z]+\s+$/.test(v)
Thanks.
Max_admin 22 Oct, 2008
you mean you got it working or it doesn't work ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 22 Oct, 2008
Hi blindman,

I think that the space needs to be inside the square brackets so that the regexp becomes /^[a-zA-Z ]+$/ but note that this will match an entry with *only* spaces. (Your version will match an alpha-string followed by a string of spaces.)

Bob
blindman 23 Oct, 2008
You're correct. Adding the space inside the bracket, /^[a-zA-Z ]+$/ , works for what I need. Sometimes I can't see the trees for the forest.

Thanks for the help.
This topic is locked and no more replies can be posted.