Adding characters to validation

DarkBlaze 08 Feb, 2009
I have a problem when writing characters like "č,ć,ž,š,đ,ž" into fields and get an error message Please use letters only (a-z) in this field.

Can I add custom characters to the exclude them so they can pass field validation ?

I took a look at mooValidation.js but I'm not that much of a coder to do it by myself....

Can anyone help ?
GreyHead 08 Feb, 2009
Hi DarkBlaze,

The validation uses a very simple RegExp that looks for [a-zA-Z0-9] If you can compose a RegExp that includes the caharcters that you want to allow then either we can amend the MooValidation file - or better, add a custom validation.

Bob

PS See here for good RegExp docs.
DarkBlaze 08 Feb, 2009
would it be a problem for you to try to compose this ?
I've read the link you posted but don't quite understand it😟

Theese are the characters I need to add
Č Ć Ž Š Đ č ć ž š đ

i tried this but it didn't work😟

				return Validation.get('IsEmpty').test(v) ||  /^\-?([1-9]{1}[0-9]{0,2}([., ][0-9]{3})*([.,][0-9]{0,2})?|[1-9]{1}\d*([, ][0-9]{0,2})?|0([.,][0-9]{0,2})?|([.,][0-9]{1,2})?) ?[$£€€šđč枊ĐČŽĆ]?$/.test(v)
DarkBlaze 08 Feb, 2009
SOLVED🙂

ok, so here's a quick one..... I managed to solve my problem...

look for the below code in "mooValidation.js" located in "components/com_chronocontact/js/"

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


and simply add the letters you wish to exclude from NOT being processed by the validation script AFTER the "a-zA-Z" letters....

In my case, i've added these letters "šđč枊ĐČŽĆ" so the code looks like:

	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Zšđč枊ĐČŽĆ]+$/.test(v)
			}],


And the form works great now🙂
GreyHead 09 Feb, 2009
Hi DarkBlaze,

Excellent -well done :-)

Bob
This topic is locked and no more replies can be posted.