Browse Source

Create format-input.js

Yuliya Shatokhina 4 năm trước cách đây
mục cha
commit
272d9b9c52
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  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, ``);
+};