[Phplib-users] OOHForms validation
Brought to you by:
nhruby,
richardarcher
From: Peter T. <pte...@te...> - 2002-02-21 23:08:26
|
Hi, I noticed some strange behaviour in the text validation logic of OOHForms: When using the Start method whith the $jvsname argument, some Javascript will be generated for validation purposes (triggered by method Validate()). This is handled in'"self_get_js" in the "of_text" extension of "of_element" in of_text.inc. The validation uses the Javascript RegExp object and evaluates against the regular expression in $valid_regex. So far so good. However, after the Javascript correctly evaluates your input string, the function "self_validate" is called. Self_validate evaluates the string again, using PHP functions ereg or eregi and $valid_regex as expression again. The problem now is that Javascript and ereg use different evaluation methods. Although there is an overlap, an expression valid for Javascript is not necessarily valid for ereg/eregi: try for instance ^[\\\w+]*$ as regexp: OK in Javascript, but not in ereg and thus causing some nasty problems in the code. Another nice one to try: ^[[:xdigit:]]*$ (this so called character class validates hexadecimal chars in ereg and has no meaning in Javascript). Do I miss something, or is this an issue? If so, a fix would be nice. As a workaround I'll stop using the Javascript option by not using $jvsname and rely on ereg/eregi in self_validate. Cheers, Peter |