From d9a6aefc0e32e226fe82d325e3ac9dd76fbdc433 Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Mon, 7 Oct 2024 00:00:34 +0900
Subject: signUpForm1: tel3 のバリデーションを tel1, tel2 で発火させる
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/SignUpForm1.tsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/SignUpForm1.tsx')

diff --git a/src/SignUpForm1.tsx b/src/SignUpForm1.tsx
index 4be29e9..9e17bef 100644
--- a/src/SignUpForm1.tsx
+++ b/src/SignUpForm1.tsx
@@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom';
 import { Form1Data, form1Schema } from './signUpSchema'
 
 export const SignUpForm1 = () => {
-  const { register, handleSubmit, formState: { errors } } = useForm<Form1Data>({
+  const { register, handleSubmit, formState: { errors }, trigger } = useForm<Form1Data>({
     resolver: zodResolver(form1Schema),
   });
   const navigate = useNavigate();
@@ -31,8 +31,8 @@ export const SignUpForm1 = () => {
         </div>
         <div>
           <label>電話番号</label>
-          <input id="tel1" type="text" {...register('tel1')}></input>-
-          <input id="tel2" type="text" {...register('tel2')}></input>-
+          <input id="tel1" type="text" {...register('tel1', { onChange: () => trigger('tel3') })}></input>-
+          <input id="tel2" type="text" {...register('tel2', { onChange: () => trigger('tel3') })}></input>-
           <input id="tel3" type="text" {...register('tel3')}></input>
           <div className="error">{errors.tel3?.message}</div>
         </div>
-- 
cgit v1.2.3

