1
Good afternoon!
How do I check if an email has been typed within a text field?
I need to identify when the user clicks outside the field, whether an email was typed or just a name, for example.
Thank you!
1
Good afternoon!
How do I check if an email has been typed within a text field?
I need to identify when the user clicks outside the field, whether an email was typed or just a name, for example.
Thank you!
1
Here the guy put in the form Submit, but it can be in the field onblur.
In this case you use Regex and the Jquery selector:
$(document).ready(function(){
   $("#form1").submit(function(){
       var email = $("#email").val();
       if(email != "") {
           var filtro = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
           if(filtro.test(email)) {
               alert("Este endereço de email é válido!");
               return true;
           } else {
               alert("Este endereço de email não é válido!");
               return false;
           }
       } else {
           alert('Digite um email!'); return false;
       }
   });
});
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.
Thank you Shura 16!
– Munir Baarini