WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7 Dynamic Text Extension
Adding E-Mail Validation (2 posts)

  1. ngoodfellow
    Member
    Posted 1 year ago #

    I am trying to add e-mail validation to a dynamic text field.

    I tried to make the class match the e-mail class: class="wpcf7-text wpcf7-form-control wpcf7-email wpcf7-validates-as-email"

    with this:

    class:wpcf7-form-control class:wpcf7-email class:wpcf7-validates-as-email
    but it doesn't appear to work

    Any advice on validating email while using the dynamic text extension?

    http://wordpress.org/extend/plugins/contact-form-7-dynamic-text-extension/

  2. Shashank Shekhar
    Member
    Posted 1 year ago #

    I am also trying to add email or any other validation to dynamic text fields which can be addded to other fields like phone, required, date,pattern etc (some field-types/validations made available by additional addon plugin for cf7).
    The above idea of adding class to dynamictext fields will work if something like below possible with this plugin
    [dynamictext dynamicemail "CF7_GET key='email'" class:wpcf7-email]
    but I tried and it doesn't work.

    I tried to add required using * like below,
    [dynamictext* dynamicemail "CF7_GET key='email'"]
    Luckily it worked, added 'wpcf7-validates-as-required' class in frontend and required validation also working!! nice.

    This proves that adding some custom classes to dynamictext fields can make all needed validations working but if this plugin can successfully parse it.

    -------
    Or, the other alternative could be, if we can use dynamictext with combining other fields like
    [email* your-email class:customclass dynamictext "CF7_GET key='email'"]

    If above can be possible, it can work like a charm with any other fields or any type and any validations, but may be not in scope of this plugin.
    ----------

    The third alternative is to use jquery to prefill any normal cf7 form fields with $_REQUEST['fieldkey'] values. This doesn't even require this dynamictext plugin.

    For ex.,
    $(document).ready(function(){
    var email = '<?php echo $_REQUEST['email'] ?>';
    var phone = '<?php echo $_REQUEST['phone'] ?>';
    $('#your-email').val(email);
    $('#your-phone').val(phone);
    });

    Here your-email, your-phone etc. are ids of fields created using contact form 7 itself.

    ---

    Thanks
    Shashank

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic