Home >Web Front-end >JS Tutorial >Before the form is submitted, the trigger function returns true and the form will be submitted_javascript skills

Before the form is submitted, the trigger function returns true and the form will be submitted_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:55:511127browse

Look directly at the code

Copy the code The code is as follows:



The onsubmit function in the example is the function that is triggered before the form is submitted
Copy code The code is as follows:

function checkform() {
var value = $( "input[name='payWay']:checked").val();
if (value == 1) {
$("#alipayment").submit();
return false;
}
return true;
}

The form will be submitted only if true is returned, otherwise it will not be submitted.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn