• Resolved Alwin

    (@wp-opti)


    I have a Number field where I like to have the folowing rule:

    When the number is not divisible by 5 there must be a warning text displayed in the Number field instead of the number.

    (for example: the number must be 5,10,15,20,25,30,35,40 and so on..)

    How can I do that?

    Thank you!
    Alwin

    • This topic was modified 6 years, 6 months ago by Alwin.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @wp-opti,

    You cannot display a text into the number field, because this value would be violating the validation rule that checks if it is a number or not.

    An alternative would be insert a HTML Content field in the form for checking the value of the number field, and force its value to the next multiple of 5. Assuming that the number field is the fieldname1, a possible code would be:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname1_"]', function(){
        var v = this.value;
        if(v%5 != 0)
        {
            v = CEIL(v,5);
            jQuery(this).val(v).change();
        }
    });
    </script>
    

    I’m sorry, but this behavior is specific to your project, if you need additional help with a custom feature not included by the plugin, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Number field warning’ is closed to new replies.