The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Custom Field Suite
New field type email and validate it (4 posts)

  1. Nilambar Sharma
    Posted 2 years ago #

    I need a new field type email. I extended cfs_field and made a class ( in a separate add-on plugin). Input data is saved nice but I could not add validation of email. How can I validate it?


  2. Nilambar Sharma
    Posted 2 years ago #

    Can plugin author reply on this please? I want to extend and add new field in CFS.

  3. Matt Gibbs
    Plugin Author

    Posted 2 years ago #

    I still need to add another hook before custom validation can be used.

    There's a cfs_custom_validation hook where you define the validation rules, but there needs to be another hook (line ~313 of form.php) to allow you to "attach" a custom rule to fields.

    Here's an example of the cfs_custom_validation hook.

    function prefix_cfs_custom_validation() {
    (function($) {
        $(function() {
            CFS.validators['valid_email']: {
                'error': 'Please enter a valid email',
                'validate': function(val) {
                    var regex = "THE EMAIL VALIDATION REGEX";
                    return regex.test(val);
            CFS.get_field_value['email'] = function(el) {
                return el.find('input').val();
    add_action( 'cfs_custom_validation', 'prefix_cfs_custom_validation' );
  4. Nilambar Sharma
    Posted 2 years ago #

    So you are saying, I need to wait for another version (after adding another hook) to use the above code?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Field Suite
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.