I've got a problem while checking manually if my inputs are matching my patterns
Here is the function I use to check it
if (!$element.attr("pattern")) return true;
let pattern = $element.attr("pattern");
let exp;
if (pattern.charAt(0) === "^") exp = new RegExp(pattern);
else exp = new RegExp('^' + pattern + '$');
if (exp.test($element.val())) return true;
else {
return false;
}
I've checked without my ifelse which I use to set the var "exp", but the result is the same.
Here is the input I want to check
<input class="k-textbox cyclique-input-popin" type="text" pattern="^[0-9]+([,][0-9])?$"/>
It has a value of 0,25, and I want it to be abble to have value like that :
- 1,25
- 1,2
- 0,2
- 20
- ...
Can have a "," or not, but can't have trailing zeros like 1,20