Hi 317th,
We don’t currently have any built in ability to limit the number of characters for a field, though this is on our feature request list (and I’ll add your vote to that, as well).
This can be done, though, with a little custom code:
/**
* Limit number of characters allowed for a field
* Apply the class "wpf-char-limit" to the field to enable.
*
*/
function wpf_char_limit() {
?>
<script type="text/javascript">
jQuery(function($){
$('.wpf-char-limit').attr('maxlength',9); // Change number to character limit
});
</script>
<?php
}
add_action( 'wpforms_wp_footer', 'wpf_char_limit' );
In case it helps, we have a tutorial with how to add custom code like this here.
Once you’ve added the code to your site, you’ll need to do a couple things:
1) Adjust the number for the max character length (if you look in the code, it’s currently set to 9).
2) Then, you’ll need to open the form builder and click on the field you want to apply this to. From that Field Options panel, you’ll need to open Advanced Options then add “wpf-char-limit” to the CSS Classes field. Here’s a screenshot so you can see exactly how that should look.
With this approach, you can apply this same character limit to any WPForms field on your site.
I hope that helps! Please let me know if you have any questions ??