<!--HTML--> <form role="form" class="form-edit-add edit-form" action="#" method="POST" enctype="multipart/form-data" onsubmit="return checkForm()"> <input type='text' name='username' value=''/> <input type='password' name='pwd' value =''/> <button type='submit'>提交<button/> <form/> <script> function checkForm() { var form = document.getElementsByClassName('edit-form'); var store_number = $("input[name='store_number']").val(); alert(store_number); //可在此修改input //进行下一步 return false; } <script/>
注意,checkForm()方法中,return true时,表单才会正常提交,为false时,浏览器将不会提交,通常是用户的密码输入错误时,终止提交。