我使用的是来自react-phone-input-international的PhoneInput,以及formik作为表单生成器,当我尝试在enter press上使用类型submit时,它不起作用。
<form onSubmit={formik.handleSubmit}>
<PhoneInput
name="mobileNumber"
country={'in'}
value={formik.values.mobileNumber}
placeholder=""
countryCodeEditable={false}
onChange={(value, country, e, formattedValue) => {
formik.setValues({
...formik.values,
"mobileNumber": formattedValue && formattedValue.replace(/ /g, '')
})
}
}
/>
<Box className="send-otp">
<Button
otpBtn
type='submit'
name={(t(`btn.send_otp`))}
/>
</Box>
</form>
我尝试输入提交按钮,但不工作。这里是codesandbox https://codesandbox.io/s/phoneinput-react-gybgzd
1条答案
按热度按时间hgqdbh6s1#
您的解决方案是添加另一个事件