JSFiddle - React, Tailwind, and code Playground
HTML
<script>
</script>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
<h2 id='result'></h2>
JavaScript
function validateForm() {
var x = document.forms["myForm"]["email"].value;
var atpos = x.indexOf("@");
var dotpos = x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
$("#result").text("");
$("#result").text(x + " is valid :)");
return false;
}
else {
alert("OK");
}
}