最近在写利用python+flask搭建后台,在写到与前端交互的时候需要对form进行数据过滤,但是在写onsubmit方法的时候老是达不到自己想要的效果,所以百度了一下这几种方法异同,顺带研究了下onclick、onsubmit、submit集合函数之间的关系和区别。
下面的介绍是在http://blog.csdn.net/wguoyong/article/details/7461511看到的:
onsubmit You can override this event by returning false in the event handler. Use this capability to validate data on the client side to prevent invalid data from being submitted to the server. If the event handler is called by the onsubmit attribute of the form object, the code must explicitly request the return value using the return function, and the event handler must provide an explicit return value for each possible code path in the event handler function. The submit method does not invoke the onsubmit event handler. submit The submit method does not invoke the onsubmit event handler. Call the onsubmit event handler directly. When using Microsoft? Internet Explorer 5.5 and later, you can call the fireEvent method with a value of onsubmit in the sEvent paramet