Mysterious “”
-
Using WP Forms Lite 1.7.1.2, I have a form that has a one-line text box. There are a number of characters that are illegal for that field and, as I don’t see a way to make a mask that allows only the legal characters anywhere in the field, I’ve hooked ‘wpforms_process’ with my own check after the form’s Submit button is clicked:
if ( !preg_match("/^[\-_' a-zA-Z0-9]+$/", $fields[1]['value']) ) { wpforms()->process->errors[TSGL_SQ_ID]['1'] = esc_html__("Illegal character(s) in search text.", 'tsglma-ttrequest'); } break;
That seems to work, for example (without the quotes) “Yee?Daltas” is disallowed, as is “%” and “Yee%D”. However, “Yee%Daltas” is entered successfully. The reason is that the code above sees the string “Yeeltas”, not “Yee%Daltas”, which passes the regular expression test. The implication is that your code is filtering “%Da” out of the field before my code gets to it. Why? And, is there anything I can do about it?
Eric Baatz
- The topic ‘Mysterious “”’ is closed to new replies.