Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validaEmail(){
- var email = $("#email").val();
- var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
- if(filter.test(email)){
- $("#email").change(function() {
- var email = $("#email").val();
- $.ajax({
- type: "POST",
- url: "compruebaemail.php",
- data: "email="+ email,
- error: function(){
- alert('errrrrrrrrror');
- },
- success: function(msg){
- if(msg == "0") {
- $("#email").removeClass("error");
- $("#email").addClass("success");
- $("#email-status").text("Dirección de email válida.");
- $("#email-status").css("color", "green");
- return true;
- } else {
- $("#email").removeClass("success");
- $("#email").addClass("error");
- $("#email-status").css("color", "red");
- $("#email-status").text("Dirección de email en uso.");
- // alert(msg);
- return false;
- }
- }
- });
- });
- }
- else{
- $("#email").addClass("error");
- $("#email-status").text("El formato de la dirección email es incorrecto.");
- $("#email-status").css("color", "red");
- return false;
- }
- }
Add Comment
Please, Sign In to add comment