Phone number
-
Hello,
i need the phone number filed to not be accept any intres less than the Limit field,
in my form the Limit field is to 11 digits, so i need the form not complete any entries less than 11 digits, ex: the user inter 9 digit so the filed must show a warning message that tells him you must enter 11 digit.
so how can i do this?
The page I need help with: [log in to see the link]
-
Hi @infofinal
I hope you’re well today!
If you have phone field validation type set to “National” or “International” the number of characters may be “flexible” but it will only accept number if it follows formats allowed for given country (so if e.g. contry has 10 and 11 digits numbers – both will be accepted; if country has only 11 digits numbers – only such numbers will be accepted and not shorter).
If you have validation set to “character limit” then there’s only upper limit – up to X characters.
In both cases, however, you can use this additional code on site to set minimum limit:
<?php function min_forminator_input_chars() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('#forminator-module-123 input[name="phone-1"]').attr('minlength', '5'); }); </script> <?php } add_action( 'wp_footer', 'min_forminator_input_chars', 99 );To add it:
– create an empty file with a .php extension (e.g. “forminator-min-digit-limit.php”)
– copy and paste code into it
– in this line$('#forminator-module-123 input[name="phone-1"]').attr('minlength', '5');make following changes
a) replace number 123 with your form ID; form ID is the number you see in form’s shortocde
b) replace phone-1 with your phone field ID (if different)
c) replace number 5 with your minimum limit– then save the file and upload it (using FTP, cPanel’s “File Manager” or similar way) to the “/wp-content/mu-plugins” folder of your site.
That’s it. You may need to clear cache on site/server but it should then work out of the box, like this:
https://app.screencast.com/eh1C3DD9kjZO3
Best regards,
AdamI have added this code to a new file and replace it into wp-content/plugins/forminator.
but its still accept phone number with less than the minimum value
Hi @infofinal,
Please be aware that the file containing the code should be placed in the /wp-content/mu-plugins directory. If the /mu-plugins directory doesn’t exist, kindly create a new one.
I hope the following guide comes in handy: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Please feel free to get back to us if you need any further clarification.
Kind Regards,
Nebu JohnI have created the mu-plugins foulder and replace the
forminator-min-digit-limit.php file to it,but still the same.
“
<?php
}
add_action( ‘wp_footer’, ‘min_forminator_input_chars’, 99 );”This is the code, is it right or there is an issue with it?
Can you please reply me????
Hi @infofinal
Thank you for response and sorry for the delay!
Please note though: we are trying to assist everyone as soon as possible but sometimes there’s some more workload and we are not able to respond “in real time” always. Let me assure you that we do our best to help as soon as we humanly can. Please don’t “bump” tickets, we’ll get back to you.
https://wordpress.org/support/forum-user-guide/faq/#should-i-bump-my-post-if-no-one-answers
As for the issue:
1. I understand that you have created “mu-plugins” folder already but can you confirm, please, if the path to the file is exactly
/wp-content/mu-plugins/forminator-min-digit-limit.php
and NOT e.g.
/wp-content/plugins/mu-plugins/forminator-min-digit-limit.php or other?
This is important.
2. Also, can you confirm that you have edited the code and configured this line correctly?
$('#forminator-module-123 input[name="phone-1"]').attr('minlength', '5');The 123 number here must be changed to the ID of your form in question. Form ID is the number you see in form’s shortcode. And the “phone-1” must be set to match your phone field ID.
I understand that asking this may cause additional delay and I’m sorry about it but both these things are critical and we need to make sure that they are correctly set.
Kind regards,
AdamHello @infofinal ,
Let us know if the above helped or if you still require our assistance.
kind regards,
KasiaHi @infofinal,
Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to re-open the thread if you need further assistance.
Regards
Nithin
The topic ‘Phone number’ is closed to new replies.