JQuery Double-Click Remote Syntax for Submitting a Form

I am trying to check the form field remotely. If the field receives focus while I am on the page, everything works fine. However, if the field never receives focus, the form requires me to double-click the Submit button to successfully submit.

I would like it to only confirm whether the field receives focus or somehow stops the form, requiring two clicks to be sent. Does anyone have any ideas?

$("#form1").validate({
    rules: {
        project: {
            required: true,
            remote: "check.php"
        }
    },
    messages: {
        project: {
            required: "Required.",
            remote: "Check Failed."
        }
    },
});

<input type="text" name="project" id="project" value="X"/>
+3
source share
4 answers
Instead of making ajax setup to false you can just set "project" "remote" async to false like this

$("#form1").validate({
    rules: {
        project: {
            required: true,
            remote: {url:"check.php", async:false}
        }
    },
    messages: {
        project: {
            required: "Required.",
            remote: "Check Failed."
        }
    },
});
+9
source
+5

You can solve the problem by adding:

$.ajaxSetup({
    async: false
});

Before you call the validation plugin.

+3
source

I had the same problem and remote: {url: "check.php", async: false} worked for me.

+1
source

Source: https://habr.com/ru/post/1787020/


All Articles