JSFiddle - React, Tailwind, and code Playground
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<form action="#" method="POST" onsubmit="return valid8(this)">
Email: <input type="text" name="email" size="30" />
<input type="submit" value="clicky-click" />
</form>
JavaScript
var pattern = new RegExp("^[0-9a-zA-Z]+@[0-9a-zA-z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$");
function valid8email(field, txt) {
if (!pattern.test(field.value))
{
alert(txt);
return false;
}
else {
return true;
}
}
function valid8(form) {
if (valid8email(form.email, "you must enter an email address") == false) {
form.email.focus();
return false;
}
}