I'm having trouble creating an expression to validate numbers between 1.0 to 4.5 accurately.
The current expression I'm using is not working as intended: /^[1-4]{0,1}(?:[.]\d{1,2})?$/
The requirement is to only allow values between 1.0 to 4.5
However,
buildInsertForm(): void {
this.insertLeavesForm = this.fb.group({
**your text**
hours: [
{ value: 4.5, disabled: true },
[
Validators.required,
Validators.pattern(**/^[1-4]{0,1}(?:[.]\d{1,2})?$/**),
],
],
});
}
Currently restricting the numbers from 1.0 to 4.0, But there is an issue with decimal points as it shows an error for numbers like 1.7, 2.8, and 3.9.
The acceptance criteria are values between 1.0 and 4.5.
https://i.stack.imgur.com/VZ6Yh.png
This image demonstrates that the input allows multiple decimal places which is incorrect,
Only a single decimal place value should be accepted.