how to set up a success message show up if form is submitted in react hooks
import React from "react";
import { useForm } from "react-hook-form";
const Example = () => {
const { handleSubmit, register, errors } = useForm();
const onSubmit = values => console.log(values);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input
name="email"
ref={register({
required: "Required",
pattern: {
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
message: "invalid email address"
}
})}
/>
{errors.email && errors.email.message}
<input
name="username"
ref={register({
validate: value => value !== "admin" || "Nice try!"
})}
/>
{errors.username && errors.username.message}
<button type="submit">Submit</button>
</form>
);
};
add message to the use after submitting the form
Also in JavaScript:
- migratory bird problem in javascript
- loopback not null
- reverse proxy using expressjs
- javascript floor
- number is even or odd fucntion in javascript
- pass params react js
- angular generat model
- axios js and react
- open google chrome in puppeteer macos
- javascript check if element has class
- new features of angular 11
- array of images javascript
- asking questions javascript in console
- jquery selector checked
- javascript example of foreach loop
- big o theory
- package json scripts multiple commands
- check if element is visible
- nesting in Jinja2 expressions
- how to add two number using jqueryu
- jquery ajax json
- react 17 hot reload not working
- selector id jquery but is variable
- jQuery exclude exteranl link for images