I have a form with a rating input box. It is not a required field. I've noticed that if the user leaves it blank, I get an exclamation mark in the content manager with the following message: "The value does not match the field type Number". It gives me the option to convert in which it changes the value to 0 or to clear the content.
I would like to leave it blank if the user does not enter any number in the input box. How would I do that?
It is documented as such, so it's a feature, I guess, but I do agree that you would expect a numeric value instead of a string when input is set to Number. The element is called "TextInput", so the "Number"-setting is just a check on input, not a change in return value.
It's prob because that input box returns a string, in this case an empty string, but still a string (and in your collection the field is a number, I guess). Just test more or less like so:
if(!$w('#someinput').value ){$w('#someinput').value = undefined };
This replaces an empty string with undefined, which is allowed in a collection number field.