I need an expression to validate numbers between 1.0 to 4.5 but it’s not working precisely for it.
Expression I’m using: /^[1-4]{0,1}(?:[.]d{1,2})?$/
Requirement is to only accept value between 1.0 to 4.5
but
buildInserForm(): 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 the issue comes in decimal points, it shows an error if entered any number between 6-9 in decimal places, like 1.7,2.8, 3.9.
acceptance criteria are 1.0 to 4.5.