Created
February 19, 2020 15:40
-
-
Save New0/f09ca32debb209cf57cadef7dd180a60 to your computer and use it in GitHub Desktop.
Set an html5 pattern on a Caldera Forms field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* HTML5 Pattern to limiot input field to 8 alphanumeric (only capitals) characters | |
*/ | |
add_filter( 'caldera_forms_field_attributes', function($attrs, $field){ | |
//IMPORTANT - Change your field ID | |
if ( 'fld_1234' === $field[ 'ID'] ) { | |
$attrs[ 'pattern' ] = '[A-Z0-9]{8}'; | |
} | |
return $attrs; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment