|
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-25 19:05:19
Hi Manuel,
i tried to apply the regularexpression validation in one of my forms, but I receive a strange behaviour.
I need a message textarea, so validated only for alphanumeric values and spaces.
My code is the following :
$form->AddInput(array(
"TYPE"=>"textarea",
"ID"=>"textarea_message",
"NAME"=>"textarea_message",
"COLS"=>80,
"ROWS"=>40,
"ValidateRegularExpression"=>array(
"^\s*[a-zA-Z,\s]+\s*$"
),
"ValidateRegularExpressionErrorMessage"=>array(
"The message area may only contain letters and digits."
),
"ValidateAsNotEmpty"=>1,
"ValidateAsNotEmptyErrorMessage"=>"It was not specified the message.",
"LABEL"=>"Submit your <u>m</u>essage",
"ACCESSKEY"=>"M"
));
All goes well client side, but on server side i always see a 'verify field' error message. I tried disabling the client side validation, but the error still remains.
What can you suggest?
Thanks
Paul
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) Manuel Lemos - 2007-05-25 20:05:21 - In reply to message 1 from Thomas
PHP POSIX regular expressions do not support \s . I think you have to enter "[ \t\n\r]" in the place of "\s".
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-26 09:16:28 - In reply to message 2 from Manuel Lemos
Hi Manuel, thanks for your prompt reply.
Nevertheless, the validation doens't work.
I ahve enabled the server side validation only, but it gives me the same error too.
My regex is now:
"^[\t\n\r]*[a-zA-Z0-9]+[\t\n\r]*\$"
But it doesn't work.
What can i do?
Thanks a lot,
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) Manuel Lemos - 2007-05-26 20:01:42 - In reply to message 3 from Thomas
What exactly do you mean by "doesn't work"? What value is it accepting that it shouldn't? Or what value is it rejecting that it should accept?
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-27 12:09:54 - In reply to message 4 from Manuel Lemos
Hi Manuel,
thanks for your patience.
The issue is simple: i am trying to make the class filter out all the the chars apart from alphanumeric chars + SPACES.
I made a regulare expression as above, since the field is a textarea type. I normally use that expression to filter chars and i have no problems.
The class throws no errors on the client side, but it doens't pass the server side validation. (it gives to me always the [Verify field ]on the right side of the field.
I cannot, for obvious reasons, disable the server side validation.
As far as the whitespaces is concerned, i think it the issue is not linked to the \s chars, since we tried putting the [:space:], which replaces all the carriage, tabs, etc... +regular whitespaces tab as you well know.
I think that the reason is that the regex is evaluated in a different way client side and server side.
It would be very useful if you could give me a solution for this. I think that your classes can be very useful to prevent XSS and CSRF attacks.
Thanks
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-27 12:24:47 - In reply to message 5 from Thomas
I remind you the regex i use in the POSIX regex:
"^[\t\n\r]*[a-zA-Z0-9]+[\t\n\r]*\$"
Thanks,
Thomas Smithson
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) Manuel Lemos - 2007-05-27 17:26:10 - In reply to message 5 from Thomas
You have not told me what is the value in the input that you want to validate but it does not work as you expect.
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-28 09:28:55 - In reply to message 7 from Manuel Lemos
Hi Manuel,
as I told you i am trying to make the class filter out all the the chars apart from alphanumeric chars + SPACES.
So, to allow only alphanumeric chars ([a-zA-Z0-9]) + SPACES.
The validation works on client side, but it's not working on the server side.
Thanks
Thomas Smithson
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) Manuel Lemos - 2007-05-28 14:23:45 - In reply to message 8 from Thomas
Please bear with me. I am asking you to give me an example of a value that you enter in the textarea input that is validated on the browser side with that regular expression, but not on the server side.
![Picture of Thomas Picture of Thomas](/graphics/unknown.gif) Thomas - 2007-05-28 15:26:59 - In reply to message 9 from Manuel Lemos
Hi Manuel, just EVERY word which contains a space
|