I have FirstName and LastName input Fields. I have a read only field called FullName which will have value based on FirstName and LastName. What ever is typed in the first name and last name input fields the Fullname will be Firstname + LastName. I am trying with below code however when i type the second field the first field value becomes undefined and full name ends up being undefined Smith
const F_Name = watch("FirstName", false);
const L_Name = watch("LastName", false);
<input id="edit-FirstName" type="text" {...register('FirstName',{ required: "Enter Your FirstName"} })} onChange={(ev)=> setValue("FullName", ev.target.value + " " + L_Name )} />
<input id="edit-LastName" type="text" {...register('LastName',{ required: "Enter Your LastName"} })} onChange={(ev)=> setValue("FullName", F_Name + " " + ev.target.value )} />
<input readOnly id="edit-FullName" type="text" {...register('FullName',{ required: "Enter Your FirstName and Last Name"} })} />