JSFiddle - React, Tailwind, and code Playground

HTML

<form action="demo.php">
  <input type="text" name="country_code" pattern="^([0-9][0-9]?|)$">
  <input type="submit">
</form>