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.