Setting pattern and message to be displayed on input validation

PHOTO EMBED

Tue Dec 06 2022 15:12:12 GMT+0000 (Coordinated Universal Time)

Saved by @jen_magpantay #javascript #react.js

<form action="/action_page.php">
  <label for="pswrd">Password:</label>
  <input
    type="password"
    id="pswrd"
    name="pswrd"
    pattern="[a-z0-9]{1,15}"
    title="Password should be digits (0 to 9) or alphabets (a to z)."
  />

  <button type="submit">Submit</button>
</form>
content_copyCOPY

https://nextjs.org/docs/guides/building-forms#form-validation-using-regular-expressions