I have an application created using Reactjs and in the application,i have a form when a user presses done or return button on iOs device i want to submit that function.As i tried but it's only working when user presses return button.
function Counter() {
const [otp,setOTp]=useState('')
const handleSubmit = (e) => {
e.preventDefault();
// conform alert
var r = window.confirm("Are you sure you want to submit?");
if (r === true) {
alert("Submitted");
} else {
alert("Cancelled");
}
}
return (
<div>
<form onSubmit={handleSubmit}>
<input type="text" placeholder="Enter OTP" value={otp} onChange={(e)=>setOTp(e.target.value)} />
<button type="submit">Submit</button>
</form>
</div>