Browse Source

fix rut bug when using backspace

master
Chris Cromer 2 weeks ago
parent
commit
6e39f6170d
Signed by: cromer GPG Key ID: FA91071797BEEEC2
  1. 11
      frontend/src/views/Agendar/AgendarComponent.js

11
frontend/src/views/Agendar/AgendarComponent.js

@ -72,7 +72,7 @@ export default function AgendarComponent() {
};
const handleRutChange = (event) => {
let value = event.target.value.replace(/\./g, '').replace('-', '');
let value = Rut.limpiar(event.target.value);
if (value.match(/[^0-9k]/ig)) {
value = value.replace(value, '');
}
@ -88,6 +88,15 @@ export default function AgendarComponent() {
else if (value.match(/^(\d)(\d{0,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);
}

Loading…
Cancel
Save