Onsubmit = "Return myfunction ();"

Source: Internet
Author: User
If you ask "why is it good or bad", I 'd like to share my opinion. When I write code, it usually causes errors with onsubmit = "Return myfunction ();" If your myfunction () method is incorrect during execution, the system returns true by default, so the form will still be submitted. Note: Will your check () be prone to errors when the code is running, such as JavaScript statements. In addition, if the browser disables javascript execution, the form will continue to be submitted. The second method you mentioned: <input name = "Submit" type = "button" onclick = "Return check () "Class =" button "value =" Submit "> it should be changed to this: <input name =" Submit "type =" button "onclick =" checkandsubmit () "Class =" button "value =" Submit "> checkandsubmit () means to check and submit the form: function checkandsubmit () {check code .... your form name. submit (); // submit form} has the following advantages: submit the form after the check is passed. If checkandsubmit has a syntax or other JavaScript error, no form will be submitted. However, the disadvantage is that if the browser disables JavaScript, the form cannot be submitted. However, normal Browsers Do not block JavaScript.


Onsubmit = "Return myfunction ();"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.