Regular expresions on custom fields

Daegaladh

Member
If would be very useful that you could set your own regular expressions to custom fields when you want them to work with a certain format.
 

Basti

Administrator
Staff member
Not so sure this ever get to be included. Its not even hard to implement and i considered this when i coded it, but the majority of users dont even have a clue what a regular expression is and it could just lead to errors all over if they do not know what they doing, not to speak about security if they do it wrong.
Will talk this through, but i have not much hope for this

If you require such thing best bet would be to rely on a plugin to create your join fields. For that we prepared a validation method which you can call like this
Code:
array_push($form_validate, validate_preg_match('input_field_name', 'input_value', '/^[a-z0-9_]+$/D'));
Last value is the expression, allowing a-z lowercase, 0-9 and an underscore
$form_validate is the main validation in join.php, using the code above you push your new method into the set of validations

This code would go for example into join_process_form hook
If you look into the vote manager plugin you also can see a few example on how to construct your html
for example a input field can be generated like so
Code:
$TMPL['join_website_extra'] .= generate_input('alter_votes', 'Amount? Based on selection above', 20);
first part is the input name attribute, second is the label text, third the input size

More validation methods, and html generate methods can be seen in sources/misc/validate.php and form.php


Not sure what you are trying to accomplish, would help to know that. Please note in case you wish to submit html coding, such as embed code, we do not suggest that. Very risky
 
Top