JSFiddle - React, Tailwind, and code Playground

by Rich Costello

HTML

<form onsubmit="return validate(this);">
  <input type="text" name="foo">
  <input type="submit">
</form>

JavaScript

function validate(form) {
  var re = /^[a-z,A-Z]+$/i;

  if (!re.test(form.foo.value)) {
    alert('Please enter only letters from a to z');
    return false;
  }
}