I want a regex in Angular for validating string and decimal
It should allow only numbers up to two decimal places and restrict user to input 0 as first no.
I have created below regex which was working fine, but it is not restricting user to enter
0 as input.
For example Accepted input
2.34
2.05
234.67
77777.87
Not allowed
0
23.5666
24.677
String and special characters
validateBatchSizeForDecimal(event: any) {
const reg = /^-?d*(.d{0,2})?$/;
let input = event.target.value + String.fromCharCode(event.charCode);
if (!reg.test(input)) {
event.preventDefault();
}
}