1, using the Submit button submission, in form forms of the OnSubmit event for form verification:
Copy Code code as follows:
<script type= "Text/javascript" >
function Onsub () {
Form validation Code
}
</script>
<form action= "" method= "" onsubmit= "javascript:onsub ();" >
2, use button or picture of the OnClick event call form validation code:
Copy Code code as follows:
<input type= "button" name= "button" id= "button" onclick= "Javascript:onsub ();"/>
However, when submitting a form in the second way, you cannot press ENTER to submit the form when the form is filled out. This gives the customer the
The feeling is different from submitting the form directly using the submit button; In order to implement this feature, just add the following JavaScript code to your page
Copy Code code as follows:
function Butonclick () {
if (Event.keycode = = 13) {
var button = document.getElementById ("Bsubmit"); Bsubmit is the ID of the botton button
Button.Click ();
return false;
}
}
Start onkeydown Event Call Butonclick () function in one of the most entries in your form; For example, the last entry in the login program is a password,
<input type= "Password" name= "userpwd" onkeydown= "Javascript:butonclick" (); "/>
This way, when you enter the password, you can press ENTER to implement form verification and login (if the username and password are correct). This is a personal summary, shared out
Everybody share!