Form submit to run javascript and then post to php script

后端 未结 4 1950
暗喜
暗喜 2021-01-13 11:13

I am currently working on a php/html/javascript project. I have a form where when the user presses the submit button, it should run a javascript function and then afterwards

4条回答
  •  走了就别回头了
    2021-01-13 11:58

    Change the action attribute to the address of the php script you're posting to. Call the javascript function in an onsubmit attribute instead of action. But you'll have to prefix it with a return statement.

    That way if validateAddImage() returns false, the form won't be submitted. But if it returns true it will.

提交回复
热议问题