Our application is still using AngularJS 1.5.11 but I've tested the included example also with version 1.7.2 and get the same results.
The problem is the strange behavior of the validateNumber
function. The validation seems to be flipping between true
and false
for each character typed. The validateMin
and validateMax
functions are working as expected.
The example code can be found here: https://codepen.io/kdbruin/pen/MBmXYz
Any insights as to why this is happening?
It seems that the regular expression is at fault here. When using
var numberRegexp = new RegExp("^[-+]?\\d+(" + (decimalSeparator === "." ? "\\." : decimalSeparator) + "\\d*)?$", "i");
the problem disappears. So it seems that the original "g" flag should not be used.