In this I will help you to set email address validation in your web application, when a user register and create their own account in your web application.
A user register details put in the register form, if they cannot fill the email box then a message is show form fill up the input field. If they are not give a appropriate email address then it’s show message again with mouser pointer go to back on the input field.
So first set a onSubmit event in your form tag and give a method name. The method name is call in a script and check the validation.
I will show you with an example and with source code. Follow the example and source code and try it in your web application.
Example and Source Code:
Form:
<form method="post" onsubmit="return form_validation();"> <input type="email" name="email" id="email" placeholder="Your Email" /> <p class="error" id="emailErr" style="color:#ff6666;"></p> <div> <input type="submit" name="submit" value="Register Now"/> </div> </form>
Script:
<script type="text/javascript"> function form_validation(){ var error=""; var email=document.getElementById("email"); if(email.value == ""){ var error="please Enter Your Email"; document.getElementById("emailErr").innerHTML=error; document.getElementById("email").focus(); return false; } else{ if(email.value.indexOf( "@" ) == -1 || email.value.indexOf(".")==-1){ var error="please Enter A Valid Email ID"; document.getElementById("emailErr").innerHTML=error; document.getElementById("email").focus(); return false; } else{ document.getElementById("emailErr").innerHTML=""; return true; } } } </script>
Related posts
Hi Samir, did you made it yourself or simply analyzed?
What do you think? https://www.mailcheck.co/
I think it good.