• Resolved pickme

    (@pickme)


    Hi,

    I have a custom input field developed by a theme into which the decimal separator (.) and letter e as well as numbers are allowed. It is a number field.

    To mask it, I used the function to add custom mask:

    function custom_masks_form_fields() {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($){
                $("input[name='year']").mask('0000');
            });
        </script>
        <?php
    }
    
    add_action('wp_footer', 'custom_masks_form_fields', 111);

    The problem is that the mask did not bypass the input of the decimal separator (.) and letter e (exponent). Is there a way to achieve this?

    Thank you

    • This topic was modified 2 years, 9 months ago by pickme.
    • This topic was modified 2 years, 9 months ago by pickme.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ivan Petermann

    (@ivanpetermann)

    Hi @pickme,

    Please try with the code below.

    function custom_masks_form_fields() {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($){
                $("input[name='year']").attr("type","tel").removeAttr("pattern").mask("0000");
            });
        </script>
        <?php
    }
    
    add_action('wp_footer', 'custom_masks_form_fields', 111);
    Thread Starter pickme

    (@pickme)

    Hi @ivanpetermann

    It worked perfectly!

    Thank you very much for your help!

    Is there a way to restrict starting from number 0 ?

    Regards

    • This reply was modified 2 years, 9 months ago by pickme.
    Plugin Author Ivan Petermann

    (@ivanpetermann)

    Hi @pickme,

    Do you still need help with your question below?

    Is there a way to restrict starting from number 0 ?

    Thread Starter pickme

    (@pickme)

    Hi @ivanpetermann

    No, it is solved. Thank you for asking and for your help!

    Regards

    • This reply was modified 2 years, 9 months ago by pickme.
    • This reply was modified 2 years, 9 months ago by pickme.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disallow characters’ is closed to new replies.