小编Mar*_*sen的帖子

onsubmit函数未定义

为什么说我没有定义我的功能?是因为我已将我的功能放在文件就绪功能中吗? - 也许我必须提一下,如果我的陈述不正确,我想使用此函数来阻止提交.

我在html中的表单标签:

<form class="text-left" method="post" action="" onsubmit="return myFunction();">
Run Code Online (Sandbox Code Playgroud)

下面是脚本(这个脚本在我的脑子部分):

$( document ).ready(function() {

    //the number generators and sum of the two numbers
    var numberOne = Math.floor((Math.random() * 10) + 1); 
    var numberTwo = Math.floor((Math.random() * 10) + 1);
    var sum = numberOne + numberTwo;

    //write the math question to the div
    document.getElementById("captchaOutput").innerHTML = numberOne+ " og " +numberTwo;
    //alert(sum);

    function myFunction(){
        var humanInput = $('#captchaInput').val();

        if(humanInput == sum){

            $("#captcha_service_err").css("display", "inline")
            $("#captchaInput").css("border-color", "red");
             return false;
        }
             $("#captcha_service_err").css("display", "none")
        $("#captchaInput").css("border-color", …
Run Code Online (Sandbox Code Playgroud)

javascript forms jquery onsubmit

1
推荐指数
1
解决办法
7810
查看次数

标签 统计

forms ×1

javascript ×1

jquery ×1

onsubmit ×1