- {options?.map((option) => (
-
- handleChange(e, option.value)}
- />
-
-
- ))}
-
- ) : null}
- >
- )
+ // type=number 정수 부호, 소수점 검사, 일부 키 허용
+ const checkInputNumber = (e) => {
+ const value = e.target.value
+ const key = e.key
+ const allowKeys = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'Tab', 'Enter', 'Control'] // 'ArrowUp', 'ArrowDown',
+ if (key >= '0' && key <= '9') {
+ return
+ }
+ if (key === '.' && !value.includes('.') && value.length > 0 && !isNaN(Number(value))) {
+ return
+ }
+ if (key === '-' && !value.includes('-') && value.length > 0) {
+ return
+ }
+ if (allowKeys.includes(key)) {
+ return
+ }
+ if (key === 'a' || key === 'c' || key === 'v' || key === 'x' || key === 'z') {
+ return
+ }
+ e.preventDefault()
+ }
+
+ // input type : text, number
+ const inputTextNumber = () => {
+ return (
+
+ {options?.map((option) => (
+
+ handleRadioCheckboxChange(e, option.value)}
+ />
+
+
+ ))}
+
+ )
+ }
+
+ return <>{type === 'text' || type === 'number' ? inputTextNumber() : type === 'radio' || type === 'checkbox' ? inputRadioCheckbox() : null}>
}