How to make useform validation in phoneInput filed from react-phone-input-2
Answers (1)
Add AnswerUsing Controller from react-hook-form
like this
<Controller name="phoneNumber" control={control} { ...register("phoneNumber", { required: true }) } render={({ field: { onChange, value } }) => ( <PhoneInput name="phoneNumber" value={value} onChange={(e, data) => { onChange(e); }} defaultCountry="TH" autoFormat countryCodeEditable id="phone-input" /> )} />