检查电子邮件ID是否存在使用1000Hz Bootstrap-Validator,AJAX& PHP

时间:2016-09-09 16:46:46

标签: php jquery ajax twitter-bootstrap bootstrapvalidator

我想检查数据库中是否已存在电子邮件ID,如果存在显示错误消息,则显示成功消息。

我想通过使用1000hz bootstrap-validator,AJAX& amp; PHP

请帮我解决这个问题

 $('form#signupform').validator().on('submit', function() {
        var firstname = $("#firstname").val();
        var lastname = $("#lastname").val();
        var fullname = firstname + ' ' + lastname;
        var email = $("#email").val();
        var phone = $("#phone").val();
        var password = $("#passwordConfirm").val();
        var dob = $("#date").val();
        var gender = $("input[name='gender']:checked").val();

        var dataString1 = 'firstname=' + firstname + '&lastname=' + lastname + '&fullname=' + fullname + '&email=' + email + '&phone=' + phone + '&password=' + password + '&dob=' + dob + '&gender=' + gender;

            $.ajax({
                type: "POST",
                url: "core/signupprocess.php",
                data: dataString1,
                cache: false,
                beforeSend: function() {
                    $("#signuperror").html("<div class='col-sm-12'><div class='alert alert-primary bg-primary'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>Sending</strong> </div> </div>");
                    alert('Sending');

                },
                success: function(data) {
                    if (data == "success") {
                        $("#signuperror").html("<div class='col-sm-12'><div class='alert alert-success bg-success'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>Please Login</strong> </div> </div>");
                                                                alert('Success');
                    } else {

                        $("#signuperror").html("<div class='col-sm-12'><div class='alert bg-error'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>Error</strong> </div> </div>");


                                                   alert('Error');
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    if (XMLHttpRequest.readyState == 4) {
                        // HTTP error (can be checked by XMLHttpRequest.status and XMLHttpRequest.statusText)

                        $("#signuperror").html("<div class='col-sm-12><div class='alert bg-warning'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>HTTP Request Error</strong> </div> </div>");

                    } else if (XMLHttpRequest.readyState == 0) {
                        // Network error (i.e. connection refused, access denied due to CORS, etc.)
                        $("#signuperror").html("<div class='col-sm-12><div class='alert bg-warning'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>Please Check Your Network Connection</strong> </div> </div>");

                    } else {
                        // something weird is happening
                        $("#signuperror").html("<div class='col-sm-12><div class='alert bg-warning'><a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a><strong>Some Error Occured</strong> </div> </div>");
                    }
                }

            });


        return false;

    });

0 个答案:

没有答案