JSFiddle - React, Tailwind, and code Playground
HTML
<input id="subscribe-email" type="email" required="required" placeholder="john.doe@example.com" />
<button type="submit" id="subscribe-submit" onClick="check()">
click me
</button>
JavaScript
function check()
{
if(!document.getElementById("subscribe-email").checkValidity())
{
//do your stuff here
alert("input not valid!");
}else
{
callMeIfValid();
}
}
function callMeIfValid()
{
//submit form or whatever
alert("valid input");
}