
I want to display an error message for the validation of email at the top of the page in red font i want to use java scripts but i dont want to use alert box what i need to do

<html>
<script>
function validate(){
var e=document.getElementById('email').value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var e = document.getElementById('email').value;
if(reg.test(e) == false) {
document.getElementById("lab").innerHTML='<font color="red"><small>Invalid Email Address</small></font>';
document.getElementById('email').value="";
return false;
}
else{
document.getElementById("lab").innerHTML=' ';
}
}
</script>
<form id="form" method="post" onsubmit="javascript:return validate();">
Email: <input type="text" id="email"><label id="lab"></label><br>
<input type="submit" value="Submit">
</form>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.