The code that handles the data and submits the form form again.

Source: Internet
Author: User

The following content is applicable to the front-end page to do the form information does not fill the point of submission or save problems

When the information is empty, generally we can not submit form form to the database, should be prompted for information is not filled or empty, this step can be done by the front-end or the back end, but in order to reduce the burden of the server, the proposal is the front-end to complete the judgment

function Check () {   var name = document.getElementById ("name"). Value;      if (name = =  Null | | name = = ") {        alert (" User name cannot be null ");        return false;   }   return true;} <form name= "mainform" action= "form.php" method= "POST"  onsubmit= "return check ()" >  <input type= "text "id=" name "/>  <input type=" Sumit "value=" Commit "/></form>

Onsubmit= "return check ()" must be added, otherwise the return value of check is even false, still commits. That is, onsubmit= "return false" does not execute commits, onsubmit= "return true" or onsubmit= "return" all execute commits.

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.