Show me a Simple javascript onSubmit handler

后端 未结 4 391
被撕碎了的回忆
被撕碎了的回忆 2021-01-19 18:01

Hello again everyone i am working on this



        
4条回答
  •  清酒与你
    2021-01-19 18:24

    OnSubmit is invoked once for the form.

    You can validate all the form fields in one onSubmit function, during one call to that function.

    function myOnSubmitHandler(theForm) { 
        if (theForm.data1.value == "") { 
            alert("This field is empty.");
            return false; // suppress form submission
        } else {
            return true; // A-OK, form will be submitted
        }
    }
    

    in HTML:

提交回复
热议问题