This is a duplicate email check question.

Asked 2 years ago, Updated 2 years ago, 49 views

function chkValidEmail() {      
    var email = document.touristSurvey.userEmail.value;
    var exptext = /^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\-]+\.[A-Za-z0-9\-]+/;
        if(exptext.test(email)==false){
        //Email format is Alphabet+Number@Alphabet+Number.Not in alphabetic + numeric format         
        alert("The Email format is invalid.");
        return;
        }else{
            chkEmail();
        }
}

function chkEmail(){
    var chk=false;
    if(document.touristSurvey.userEmail.value != ''){
        var userEmail = $("#userEmail").val();
        $.ajax({ 
               url: "emailChk.or", 
               type: "POST",
               data: {"userEmail" : userEmail},
               dataType:"text",
               cache: false,
               success: function(result){
                   if(result!="0") {
                       alert("The email is duplicated.");
                       return;
                   }else{
                       submitOn();
                   }
               }
        });
    }
}

function submitOn(){
    document.getElementById("submit_btn").innerHTML = "On saving... Please wait.";
    document.touristSurvey.submit();
}

It's a strip that checks your email

DB is writing msql.

Most of the double check by e-mail and receiving it in the DVD is going well, but...

We found that we received duplicate emails. (This is about 1/100)

I don't know why. <

javascript ajax jquery

2022-09-21 21:19

1 Answers

In MySql, set unique constraint in the email column.

This is because the timing of checking for duplication and the time of actual insert are different.

The storage stage must guarantee that it is unique.


2022-09-21 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.