Use html() or text() to set the contents of the div errors:
$('#errors').html("<p>Please enter a valid email</p>");
And so as not to display anything when email is true , add else to the if :
if (email === "false"){ $("#errors").html("<p>Please enter a valid email</p>"); } else { $("#errors").html(""); }
Also note that instead of = I used === . This is because using a single equal sign ( = ) will simply set the email variable to false and will not actually verify the equality.
source share