Invalid characters

In a number field, if the user enters a word or letter. It default to to zero. I tried validation rules for this but it doesn’t work.

It would be great to have a pop up which states invalid character or something like that.

I know this is an old post but I would like to add my 2 cents since I was struggling with this yesterday for a different reason.

I have some numeric field that must be complied by an operator through a mobile phone. Mobile phones can prompt a numeric keyboard in certain cases and I was seeking for this behaviour since it's time consuming to switch every time to the "numeric" keyboard of the phone (and leads to mistakes).

What I am doing, is simply changing the type of input field from "text" to "number" through Javascript:

$(document).on('knack-view-render.view_xxx', function(event, view, data) {
$("#field_yy").prop('type' , 'number');

This will implicitly add some controls (you can't type any characters but only numbers and certain operators such as "-" and "e") and will automatically prompt the numeric keyboard when I focus on this field.

Hope this helps

Hi Belinda -

There are a couple of ways to set up validation in order to only allow numbers to be entered. A number field 'allows' non-digit characters to be entered, but converts them to 0s upon submit.

1. Number field type. If your set up requires additional 'number' functionality such as being used in an equation, you can use a Validation Rule set up in the following manner: "When" "Number" "is lower than" ".5."

Then, if letters are entered into the form field, (like asdf), Knack will attempt to convert this to a 0. Since 0 is lower than .5, it returns the error message.

2. Short Text field type. If you do not need additional 'number' functionality such as being used in an question, you can use a Short Text field outfitted with a Validation Rule with a simple regular expression of \d to allow only numbers.

Note that at this time Number fields do not allow regular expressions to be used, so this setup requires a Short Text field type.

Let me know if that doesn't work for you!

Thank you! That works well.