Disable/Not Allow minus for number fields?

Hi, I've just created and presented a form for a client and they have asked about the number fields not being allowed to go minus, is this possible? I tried setting the Min to 0 but that didn't work, any ideas? Thanks

Dear @Nicola_01,
Should work, I've used the following code:

fd.rendered(function(){
    fd.field('Number1').widgetOptions = {
       min: 0
    }
});

Here it is - NumberAbove0

Perfect, thanks as always!!

Dear @Nikita_Kurguzov !
Is it possible to set minimum value for multiple number fields (using jquery perhaps)?
This does not work unfortunately.

$(".numberFields").widgetOptions = {min: 0}

Nor

$(".numberFields").find("input").attr("min","0"}

So, is it possible?
Thanks.

I use Forms for Sharepoint 2019.

Hello @Janos_Nagy,

Why don't you want to use this code?

    fd.field('Number1').widgetOptions = {
       min: 0
    }

I do use that code, but as I have a lot of number fields on many forms I would have liked to know if it is possible to simplify things and save timeand effort.

@Janos_Nagy,

You can list all internal names of number fields and change its min property using the code:

var fieldNames = ['Number0', 'Number1', 'Number2'];

fieldNames.forEach(function(n){
    fd.field(n).widgetOptions = {
       min: 0
    }
})
1 Like