Explorar el Código

Create format-input.js

Yuliya Shatokhina hace 4 años
padre
commit
272d9b9c52
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      js/utils/format-input.js

+ 7 - 0
js/utils/format-input.js

@@ -0,0 +1,7 @@
+const LEAD_ZERO = /^0+/;
+const NOT_NUMBERS = /[^\d]/g;
+
+
+export const formatInput = (input) => {
+  return input.value.replace(NOT_NUMBERS, ``).replace(LEAD_ZERO, ``);
+};