Form validation cannot be numeric and 'not required'


#1

My form field looks like this:

            validation: "numeric",
            value: "100"
            required: false

By my logic this should allow an empty field or any valid number but the validation fails when the field is empty ie. it doesn’t seem possible to have a numeric field that is not mandatory


#2

This is the expected behavior.
as the “numeric” validation rule means that the field can only contain the number, while the empty string is not a number.
In your case you may try to create a custom validation rule.
You can find a tutorial here:
https://docs.dhtmlx.com/suite/form__work_with_form.html#validatingform


#3

So what you are saying is that a non-required numeric field will force the user to enter a zero in that field?
That behaviour doesn’t seem correct to me


#4

I apologize for the delay.
I understand. Thank you for your report. I’ve sent your suggestion to the dev team, validation mechanics will be updated to suit such situation.
Currently, I can only suggest you create your own custom validation rule.


#5

NOw you are able to define the inputType to your form input control:

    {
      type: "input",
      inputType:"number",
      label: "enter the number",
      name: "count"
    },

to use it instead of the validation.