onsubmit refresh html form

前端 未结 5 701
春和景丽
春和景丽 2021-01-12 00:54

I\'m trying to use Javascript to submit the form\'s data. Here\'s the html.

//input fields here
5条回答
  •  深忆病人
    2021-01-12 01:14

    You need to actually return false from your inline dom-0 handler. So change

    onsubmit = "post();">
    

    to

    onsubmit = "return post();">
    

    Or you could give your form an id and do this:

    Then from a safe location in which your dom is ready:

    document.getElementById("form1").onsubmit = post;
    

提交回复
热议问题