How to validate non-numeric input in number field

Hi,

Is there a way to trap a non-numeric value entered by a user in a number field.

If i type the text “aa” in a number field, the text turns red, but there
is no message and the on-error method of the solution is not fired.

Would the downloadable IT2BE Tools node (which includes a function to test for whether a string contains a number or not) help here?

You can also use standard methods. For example, you can do this:

var vNumber = 'a1234aa';
var vResult = parseFloat(vNumber)  // will evaluate to NaN - not a number
if (vResult == vNumber) {
  // value is a float
}

This

var vNumber = '1234aa';
var vResult = parseFloat(vNumber)  // will evaluate to 1234
if (vResult == vNumber) {
  // value is a float
}

There is also a parseInt to try to convert a String to an Integer.
Hope this helps.

Thanks,

Will try this.