Conversation
supportHi, Using this function: function custom_masks_form_fields() { ?> <script type="text/javascript"> jQuery(document).ready(function($){ $("input[name='money']").mask('000.000.000.000.000', { reverse: true }); }); </script> <?php } add_action('wp_footer', 'custom_masks_form_fields', 111); How can set a minimum number, ie a min amount of money, for example restrict the number to start from 0 ? Thank you This topic was modified 4 years, 3 months ago by pickme . This topic was modified 4 years, 3 months ago by pickme . This topic was modified 4 years, 3 months ago by pickme . This topic was modified 4 years, 3 months ago by pickme .
Hi @pickme , Please try with the code below. function custom_masks_form_fields() { ?> <script type="text/javascript"> jQuery(document).ready(function($){ $("input[name='money']").attr("type","text").mask("000.000.000.000.000",{reverse:true}).on("blur, keyup, change",function(e){const money=parseInt($(this).val().replace(/\./g,""));if((money * money)==0){$(this).val("");}}); }); </script> <?php } add_action('wp_footer', 'custom_masks_form_fields', 111); When the value is zero, the script will clear the field.
Hi @ivanpetermann This code worked as well. Thank you! This reply was modified 4 years, 3 months ago by pickme .
Hi @ivanpetermann Is there a way to set a minimum number and a maximum number, in addition to restricting the entry starting with 0? The code above works for the 0. Below the minimum number, the number may be restricted entry or clear itself. Same for the number above the maximum number. Thank you This reply was modified 4 years, 3 months ago by pickme . This reply was modified 4 years, 3 months ago by pickme . This reply was modified 4 years, 3 months ago by pickme .
Hi @pickme , Please try with the code below. function custom_masks_form_fields() { ?> <script type="text/javascript"> jQuery(document).ready(function($){ $("input[name='money']").attr("type","text").mask("000.000.000.000.000",{reverse:true}).on("blur, keyup, change",function(e){const money=parseInt($(this).val().replace(/\./g,""));if((money * money)==0){$(this).val("");}}); }); </script> <?php } add_action('wp_footer', 'custom_masks_form_fields', 111); When the value is zero, the script will clear the field.
Hi @ivanpetermann This code worked as well. Thank you! This reply was modified 4 years, 3 months ago by pickme .
Hi @ivanpetermann Is there a way to set a minimum number and a maximum number, in addition to restricting the entry starting with 0? The code above works for the 0. Below the minimum number, the number may be restricted entry or clear itself. Same for the number above the maximum number. Thank you This reply was modified 4 years, 3 months ago by pickme . This reply was modified 4 years, 3 months ago by pickme . This reply was modified 4 years, 3 months ago by pickme .