How to display a calendar instead of textinput to have the date with REACT?

Viewed 123

how can I do to have a calendar instead of having a textinput in my form please ??

export default function InterviewSettings() {
  const [date, setDate] = useState("");
  const [msg, setMsg] = useState("");    
  ...    
  return (
    <>
      <form onSubmit={handleSubmit}>
        <label>
          Date:
          <input
            type="text"
            value={date}
            placeholder="DD/MM/YY"
            onChange={(e) => setDate(e.target.value)}
          />
        </label>
      </form>
    </>
  );
}
2 Answers

You can simply change the input type from type="text" to HTML5 date type type="date", this should do the trick.

Related