Ready to get started?Download WordPress


Custom Field Suite
Feature request - reg expressions (3 posts)

  1. texasguy911
    Posted 3 years ago #

    It would be cool if for adding a new field input type text you could provide 2 additional fields. First field would take a regular expression string, another just a text for an error when the value does not pass regular expression.

    This way, those who know power of regular expressions could provide for fields a good checking of the inputted data (you could also provide a drop down with most common like numbers only, one numbers, emails, website, etc). However, just a custom regular expression would be very cool, most programmers could make up their own one.

    I think this would make this plugin a much more powerful one since it would allow field data checking.


  2. web559
    Posted 3 years ago #

    This would be cool.

  3. logikal16
    Plugin Author

    Posted 3 years ago #

    I like the idea -- validation is something we're going to need.

    Instead of adding validation logic to each field, would you be OK with some sort of validation hook? For example:

    add_filter('cfs_validators', 'my_custom_validator');
    function my_custom_validator($validators) {
        $validators['valid_email'] = array(
            'label' => 'Valid Email',
            'field_types' => array('text'),
            'logic' => 'is_valid_email', // function name or regex
            'error_text' => 'Please enter a valid email for {@label}',
        return $validators;

    That way, we could add validators that can be applied to multiple fields, and multiple field types.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic