Skip to content

Instantly share code, notes, and snippets.

@adczk
Created September 20, 2023 11:39
Show Gist options
  • Save adczk/a10af218a726f2f6e2591905007def4c to your computer and use it in GitHub Desktop.
Save adczk/a10af218a726f2f6e2591905007def4c to your computer and use it in GitHub Desktop.
Forminator - set minimum characters limit for field
<?php
/**
* Plugin Name: [Forminator] - set minimum characters limit for field
* Description: [Forminator] - set minimum characters limit for field
* Author: Adam @ WPMUDEV
* Author URI: https://wpmudev.com
* License: GPLv2 or later
*
* Tested with Forminator 1.26 but should work with older too probably
*
* use as MU plugin
*
* configure as per comment in the code below
*
**/
function min_forminator_input_chars() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// replace 3010 with your form ID
// replace "phone-1" with your field ID
// replace 5 with your minimum characters limit
$('#forminator-module-3010 input[name="phone-1"]').attr('minlength', '5');
});
</script>
<?php
}
add_action( 'wp_footer', 'min_forminator_input_chars', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment