JSFiddle - React, Tailwind, and code Playground
by ijse
HTML
<form>
<input type="text" id="studentEmail" /><div class="studentEmailError">tt</div>
<input type="text" />
<input type="submit" class="submit" value="Submit" />
</form>
JavaScript
$("#studentEmail").blur(function() {
debugger;
$(".studentEmailError").empty();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
email1Value = $(this).val()
if(!emailReg.test($(this).val())) {
$(".studentEmailError").html('Please enter a valid email');
validationError = "true";
}
else {
validationError="false";
}
});
$(".submit").click(function() {
if (validationError == "true") {
return false;
}
else if (validationError == "false"){
//PROCESS INFORMATION
}
});