• Resolved yasbadri

    (@yasbadri)


    Hello,

    I would like to add the step attribute to the field type number but I can’t find any options for it? I tried to add javascript but the code does not work. On safari, it adds the step after each number. For example for a step of 5 -> 0/05/055/0555… On chrome, it does not take the code. Here is the code:

    <script>
    $( document ).ready(function() {
    	inputField = document.getElementsByName("fieldname5_1");
    	inputField[0].setAttribute("step", 5);
    });
    </script>

    Can you help me please ? Thanks by advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @yasbadri

    Thank you very much for using our plugin. Please, insert an “HTML Content” field in the form and enter the following piece of code as its content:

    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    getField('fieldname5').jQueryRef().find('input').prop('step', 5);});
    </script>

    Best regards.

    Thread Starter yasbadri

    (@yasbadri)

    Thanks for your come back, but this code not run correctly. The value gone to max and just the min button run. Here is a screenshot to better understand. https://www.loom.com/share/6e161ea18b764fe8b2a170163f12d902

    Plugin Author codepeople

    (@codepeople)

    Hello @yasbadri

    Thank you very much. I detected the issue cause and will include the definitive solution in the next plugin update. To fix it in your plugin copy, please, replace the content on the “HTML Content” field with the following piece of code:

    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    getField('fieldname5').jQueryRef().find('input').attr('step', 5);
    jQuery(document).off('click', '#fbuilder .cff-spinner-down,#fbuilder .cff-spinner-up');
    jQuery(document).on('click', '#fbuilder .cff-spinner-down,#fbuilder .cff-spinner-up', function () {
        var u = jQuery(this).hasClass('cff-spinner-up'),
        e = jQuery(this)[u ? 'prev' : 'next']('input'),
        o,s,m,v;
    
        if (e.length) {
            o = getField(e.attr('id'), e[0].form);
            s = (e.attr('step') || 1) * 1;
            m = e.attr(u ? 'max' : 'min');
            v = o.val();
            if (e.hasClass('percent')) v = PREC(v * 100, 4) * 1;
            if (u) v += s;
            else v -= s;
            if (m) v = u ? MIN(v, m) : MAX(v, m);
            o.setVal(v);
            e.valid();
        }
    });
    });
    </script>
    

    Best regards.

    Thread Starter yasbadri

    (@yasbadri)


    Perfect ! Thank you for your very very quick return. great plug-in

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Input with step’ is closed to new replies.