How to make .js file to load verification file?

Husbarn

Junior Member
Joined
Dec 19, 2012
Messages
160
Reaction score
20
I have a script which verifies from a .js file if something is typed correctly. I want to add another code to that script and i have a file verify.php which I want to load from a .js file. Verify.php verifies if my newly added line is correct, but it must be verified from a .PHP file. So I need something to "redirect" that verification through a .js file.

Any ideas on this?
 
Last edited:
Where do you want the verification to take place? On the client or on the server or both? Client side you can't run PHP, only JavaScript. On the server you can run both, but usually not at the same time. PHP you would chose in an environment like Apache/PHP. The JavaScript solution would be most likely be based on a Nodejs webserver.

Can you elaborate what you exactly want to do?
 
Where do you want the verification to take place? On the client or on the server or both? Client side you can't run PHP, only JavaScript. On the server you can run both, but usually not at the same time. PHP you would chose in an environment like Apache/PHP. The JavaScript solution would be most likely be based on a Nodejs webserver.

Can you elaborate what you exactly want to do?

This is .js file:

Code:
$(document).ready(function () {
    function u() {
        if ($("#agt_mail_name").val() == "") {
            t.addClass("error");
            n.text("Please Enter Your Name");
            n.addClass("message_error2");
            return false
        } else {
            t.removeClass("error");
            n.text("");
            n.removeClass("message_error2");
            return true
        }
    }
    function a() {
        var e = 0;
        if ($("#agt_mail_email").val() == "") {
            e = 1
        } else if ($("#agt_mail_email").val() != "") {
            var t = $("#agt_mail_email").val();
            var n = /^[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 (n.test(t)) {
                e = 0
            } else {
                e = 1
            }
        }
        if (e) {
            r.addClass("error");
            i.text("Please Enter valid Email Address");
            i.addClass("message_error2");
            return false
        } else {
            r.removeClass("error");
            i.text("");
            i.removeClass("message_error");
            return true
        }
    }
    function f() {
        if ($("#agt_mail_msg").val() == "") {
            s.addClass("error");
            o.text("Please Enter Comments");
            o.addClass("message_error2");
            return false
        } else {
            s.removeClass("error");
            o.text("");
            o.removeClass("message_error2");
            return true
        }
    }
    function l() {
        document.getElementById("agt_mail_name").value = "";
        document.getElementById("agt_mail_email").value = "";
        document.getElementById("agt_mail_phone").value = "";
        document.getElementById("agt_mail_msg").value = ""
    }
    var e = $("#agt_mail_agent");
    var t = $("#agt_mail_name");
    var n = $("#span_agt_mail_name");
    var r = $("#agt_mail_email");
    var i = $("#span_agt_mail_email");
    var s = $("#agt_mail_msg");
    var o = $("#span_agt_mail_msg");
    t.blur(u);
    r.blur(a);
    s.blur(f);
    t.keyup(u);
    r.keyup(a);
    s.keyup(f);
    e.submit(function () {
        if (u() & a() & f()) {
            return true
        } else {
            return false
        }
    })
})

It verifies if everything is typed correctly in a inquiry form. So if you type something wrong, it won't allow to send an inquiry.

I want to add a code which could verify "verify.php" file through it (trying to install google recaptcha). So basically I need this file to verify "verify.php" file and if captcha is typed correctly, it could allow an inquiry to be sent.
 
If I understood correctly you are looking for ajax

http://api.jquery.com/jquery.ajax/

On the other side I know you can implement recaptcha without ajax too.

You should implement checking in your submit.php or whatever (where actually inquiry gets saved)
 
Why do u want a java file to do this pretty sure this can be done within php right?
 
Why do u want a java file to do this pretty sure this can be done within php right?

Yes, but the problem is that I don't know how. Any ideas would be appreciated. :)
 
Back
Top