Using the java script to prevent form submission but the html version of html also doesn't work

123 2

In order to use the ajax table to prevent form submission from a java script, the browser built-in form validation also doesn't work.
This will still have to be a java script to write validation, and the new features of the form are equal in that case.
What's the solution.

3 Answers

105 4

It should be the java script code in the block to block the submit button 's default event, so the browser ignores the trigger event, and the browser is.
The default event isn't blocked, but the onsubmit method is covered. The default event is blocked in the address bar of the primary key when the browser calls the submit event, which isn't invoked if the browser isn't authenticated. All right, let the browser verify it first, and then submit it.

95 5

Don't use click to prevent form submission. This prevents the form form from submitting a jump and keeps the validation of the w3c form.

$("form").submit(function(){
//这里是要执行的代码
 event.preventDefault();
});
...