Title: Mask doesn&#039;t work without brackets
Last modified: August 20, 2016

---

# Mask doesn't work without brackets

 *  [scottydog0](https://wordpress.org/support/users/scottydog0/)
 * (@scottydog0)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/)
 * Hi,
 * This plugin is great, but I’ve found an issue when changing the phone mask. It
   seems that when I use a mask like “999-999-9999” instead of “(999)999-9999”, 
   the phone mask comes out as blank.
 * Thanks,
    Scott
 * [http://wordpress.org/extend/plugins/contact-form-7-phone-mask-module/](http://wordpress.org/extend/plugins/contact-form-7-phone-mask-module/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512040)
 * Hi Scott,
 * Can you paste your shortcode here?
 * Regards,
    Gabriel
 *  Thread Starter [scottydog0](https://wordpress.org/support/users/scottydog0/)
 * (@scottydog0)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512078)
 * Sure, here’s what I’m using:
 * [phone* Phone mask:999-999-9999]
 * -Scott
 *  Plugin Author [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512229)
 * Hi Scott,
 * Apologies for the delay.
 * Your mask is not working because the way CF7 deals with the parentesis.
 * If I put a mask like this
 * `[phone* Phone mask:(99)9-999-9999]` CF7 parses it as
 *     ```
       Array
       (
           [type] => phone*
           [name] =>
           [options] => Array
               (
               )
   
           [raw_values] => Array
               (
               )
   
           [values] => Array
               (
               )
   
           [pipes] =>
           [labels] => Array
               (
               )
   
           [attr] => Phone mask:(99)9-999-9999
           [content] =>
       )
       ```
   
 *  but if the mask has no parentesis, e.g. `[phone* Phone mask:999-999-9999]` the
   result from CF7 parser is
 *     ```
       Array
       (
           [type] => phone*
           [name] => Phone
           [options] => Array
               (
                   [0] => mask:999-999-9999
               )
   
           [raw_values] => Array
               (
               )
   
           [values] => Array
               (
               )
   
           [pipes] => WPCF7_Pipes Object
               (
                   [pipes] => Array
                       (
                       )
   
               )
   
           [labels] => Array
               (
               )
   
           [attr] =>
           [content] =>
       )
       ```
   
 * I’ll have to think about a way to deal with both situations.
 * Regards,
    Gabriel
 *  Thread Starter [scottydog0](https://wordpress.org/support/users/scottydog0/)
 * (@scottydog0)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512231)
 * I looked at your code. Maybe something like this:
 *     ```
       $tokens = array( 'mask' => 'mask:', 'alternate_mask' => 'aMask:', 're_do' => 'reDo:', 're_undo' => 'reUndo:');
   
       if (!empty( $tag['attr']) {
       	foreach($tokens as $var => $token){
       		if (strpos($token, $tag['attr'])) {
       			${$var} = preg_replace("/.*?$token([^\s]+)\s.*/",'$1',$tag['attr']);
       		} else {
       			${$var} = '';
       		};
       	};
       } else if (!empty($tag['options'])) {
       	foreach ($tag['options'] as $value) {
       		foreach($tokens as $var => $token){
       			if (strpos($token, $value)) {
       				${$var} = preg_replace("/.*?$token([^\s]+)\s.*/",'$1',$value);
       			} else if(!isset(${$var})) {
       				${$var} = '';
       			};
       		};
       	};
       };
       ```
   
 * I haven’t tested it yet, so my regex may be off, but this should properly parse
   out the options in either situation.
 *  Plugin Author [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512233)
 * Hi Scott,
 * Thanks for the code.
 * However there are other situations where the plugin is failing, for example, 
   when one uses ‘watermarks’ or when one use masks with spaces.
 * I am thinking about removing the Tag Generator panel and creating a new menu 
   entry for just the masks.
 * It won’t be so tightly integrated to Contact Form 7, but it would be a way to
   solve all those issues.
 * How does it sound to you? Seems that is would be good or bad?
 * Regards,
    Gabriel
 *  Thread Starter [scottydog0](https://wordpress.org/support/users/scottydog0/)
 * (@scottydog0)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512234)
 * I’m not sure about “watermarks”. I’d need to see an example. I think keeping 
   things tightly integrated is probably best. A separate interface could get confusing.
   What problem have you had w/ spaces so far? Have you tried using a space character
   placeholder?
 * Thanks,
    Scott
 *  Plugin Author [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512240)
 * Hi Scott,
 * Watermarks are part of CF7:
    [http://wordpress.org/support/topic/plugin-contact-form-7-how-to-add-watermark-to-text-field?replies=2](http://wordpress.org/support/topic/plugin-contact-form-7-how-to-add-watermark-to-text-field?replies=2)
 * The issue with spaces is that I use them as a separator for the mask options,
   I am not keen using a placeholder because it would defeat the purpose of having
   simple shortcodes.
 * In hindsight, I would not remove the Tag Generator panel, instead just the mask
   options.
 * Those would go in a separate panel.
 * Thanks to all your input and help.
 * Would you like to see a preview of the new version?
 * Regards,
    Gabriel
 *  Thread Starter [scottydog0](https://wordpress.org/support/users/scottydog0/)
 * (@scottydog0)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512243)
 * Sure, I’d like to see the new version.
 * Thanks,
    Scott
 *  Plugin Author [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * (@gabriel-reguly)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512279)
 * Hi Scott,
 * The new version of Contac Form 7 allows telephone fields, so I am thinking of
   changing the purpose of this plugin to masks only.
 * Currently I am overloaded with work, but once I can start on this I will contact
   you again.
 * Regards,
    Gabriel

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Mask doesn't work without brackets’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-phone-mask-module_394a4f.
   svg)
 * [Contact Form 7 Phone Module](https://wordpress.org/plugins/contact-form-7-phone-mask-module/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-phone-mask-module/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-phone-mask-module/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-phone-mask-module/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-phone-mask-module/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-phone-mask-module/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Gabriel Reguly](https://wordpress.org/support/users/gabriel-reguly/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/mask-doesnt-work-without-brackets/#post-3512279)
 * Status: not resolved