Validator properties with whitespace

2 views
Skip to first unread message

Daniel Lohse

unread,
Oct 22, 2009, 11:13:03 AM10/22/09
to mootool...@googlegroups.com
Hey there,

Form.Validator has been in use in our company for a little while now
and it works perfectly.

One problem I've encountered today is, that the validator properties
in the class attribute don't work as expected.

Take a look here: http://mooshell.net/NQ8jM/

Now, to explain: we want to pass the error messages from the CMS to
the form by using these validator properties.
In the first example, everything is properly wrapped in single quotes
and there are no spaces in the value (just "Required!").
In the second example there is one whitespace ("Fill in!").

So, I had a look at the source and it's splitting the class attribute
value by a space, I thought it was a heavy regex at work.

Does anyone have an idea as to what I could do to allow whitespace in
the validator properties?
I also think that someone else should have encountered this already,
spaces there should not be uncommon as the documentation also only
says to properly escape everything.
I can't escape a space (or can I?) and using a non-breaking space
entity is also not an option as this text doesn't get wrapped when
injected into a web page.


Cheers, Daniel

Fli7e

unread,
Oct 22, 2009, 12:47:08 PM10/22/09
to MooTools Users
Have you tried url encoding / decoding using escape() und unescape()?

This would encode a space to %20.

Like:

reqchk-byparent-error:unescape("Fill%20in!")

should do the trick :-)

Daniel Lohse

unread,
Oct 22, 2009, 1:22:35 PM10/22/09
to mootool...@googlegroups.com
Yay, thank you, that works like a charm! :)

For others that might have the same problem, I updated the MooShell
snippet
but it creates a new entry upon every change, so here's the new URL: http://mooshell.net/9Cp8Z/

Thanks again! How's your name again? :)


Daniel

Fli7e

unread,
Oct 23, 2009, 4:16:09 AM10/23/09
to MooTools Users
My name was Fli7e (or if you are about my realname, it's Timo) :-)

Glad to be of help.

Daniel Lohse

unread,
Oct 23, 2009, 4:18:55 AM10/23/09
to mootool...@googlegroups.com
Yes Timo, my question was about your real name, that was nowhere to be
found. :)

Thanks again! Daniel

Reply all
Reply to author
Forward
0 new messages