Determine whether the returned data is empty. If so, abort the submission of the form.

function check() {//js
        var text = document.getElementById("xh").value;//id
        if (text == "") {
            alert("");//
            return false;//false
        }
        if (!(/(^[1-9]\d*$)/.test(text))) {
            alert("");//
            return false;//false
        }
        var student_id = $("input[name="student_id"]").val();
        $.post("<%=basePath%>user/queryByUser", 
            { student_id : student_id }).done(function(data) {
            console.log(data.result);
            if (data == null || data == "") {
                console.log("");
                alert("");
                return false;
            } else {
                console.log("");
            }
        }).fail(function() {
            console.error("");
        });
        return true;//
    }
</script>
<body>
    <div class="listDIV">
        <table id="FileTable" border="1" width="50%" height="50%"
            style="text-align: center;">
            <form action="<%=basePath%>user/one" method="post">
                <input type="text" id="xh" name="student_id" placeholder="">
                <button class="glyphicon glyphicon-select" onclick="return check();"></button>
            </form>

return false does not abort form submission

Aug.30,2021

you have already submitted it here. The backend received an empty return data. The raw rice is cooked and ripe. It's no use stopping.


function handleSubmit () {

if (document.form.name.value == "") {
    console.log("")
    return false
} 

}

< form name= "form" method= "post" action= "- sharp" onsubmit= "return handleSubmit ()" >

<input name="name" type="text" id="id">
<input type="submit" name="Submit" value="">

< / form >


ajax is set to Synchronize request

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c0d148-32b4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c0d148-32b4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?