add sync form validate

This commit is contained in:
smanylov
2025-12-22 13:02:39 +07:00
parent 02ebf8aa07
commit e26a8c4742
4 changed files with 111 additions and 30 deletions
+6 -2
View File
@@ -5,9 +5,10 @@ import styles from '@/app/styles/login.module.scss';
interface PhoneInputProps {
phoneState: string | undefined;
validateHandler: (e: ChangeEvent<HTMLInputElement>) => void;
}
export default function PhoneInput({ phoneState }: PhoneInputProps) {
export default function PhoneInput({ phoneState, validateHandler }: PhoneInputProps) {
const [phone, setPhone] = useState(phoneState ? phoneState : '');
const formatPhoneNumber = (value: string, isBackspace: boolean): string => {
@@ -73,7 +74,10 @@ export default function PhoneInput({ phoneState }: PhoneInputProps) {
className={`${styles['form-input']}`}
placeholder="+7 (999) 123-45-67"
value={phone}
onChange={handleChange}
onChange={(e) => {
handleChange(e);
validateHandler(e);
}}
/>
)
}