fix rut bug when using backspace
This commit is contained in:
parent
17c6278997
commit
6e39f6170d
@ -72,7 +72,7 @@ export default function AgendarComponent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRutChange = (event) => {
|
const handleRutChange = (event) => {
|
||||||
let value = event.target.value.replace(/\./g, '').replace('-', '');
|
let value = Rut.limpiar(event.target.value);
|
||||||
if (value.match(/[^0-9k]/ig)) {
|
if (value.match(/[^0-9k]/ig)) {
|
||||||
value = value.replace(value, '');
|
value = value.replace(value, '');
|
||||||
}
|
}
|
||||||
@ -88,6 +88,15 @@ export default function AgendarComponent() {
|
|||||||
else if (value.match(/^(\d)(\d{0,2})$/)) {
|
else if (value.match(/^(\d)(\d{0,2})$/)) {
|
||||||
value = value.replace(/^(\d)(\d{0,2})$/, '$1.$2');
|
value = value.replace(/^(\d)(\d{0,2})$/, '$1.$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value.substr(value.length - 1, 1) === '-') {
|
||||||
|
value = value.substr(0, value.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.substr(value.length - 1, 1) === '.') {
|
||||||
|
value = value.substr(0, value.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
setRut(value);
|
setRut(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user