JavaScript programming: JavaScript form Programming
Source: Internet
Author: User
7. JavaScript form programming: Get form reference: varoformdocument. getElementById (& quot; form1 & quot;); varoformdocument. forms [0]; if no subscript is required, the set of all forms is obtained. Varoformd... syntaxHig 7. JavaScript form programming: Get form reference: var oform = document. getElementById ("form1"); var oform = document. forms [0]; if no subscript is required, the set of all forms is obtained. Var oform = document. forms ["formz"]; get the form named formz. Access form field: var temp = oform. elements [0]; obtain the first field of the form. Var temp = oform. elements ["text1"]; The field named text1 is obtained. Var temp = oform. textbox1; the field textbox1 is obtained. Var temp = oform ["text box 1. Common form fields: disabled attributes: user input and submission are not allowed. Form attribute: This attribute returns a form containing fields. Blur () method: This method causes the form field to lose focus. Focus () method: This method causes the form field to get the focus. Blur event: this event is triggered when the form field loses focus, and then the onblur event handler is executed. Focus event: this event is triggered when the form field obtains focus, and then the onfocus event handler is executed. Form submission: oform. submit (); form Reset: Unlike submit (), the reset event is still triggered using the reset () method, and the onreset event handler is still executed. Form Verification: prevents errors before they occur. Form validation best practices: 1. it must be helpful to the user; 2. 3. maxlength control length; 4. show all errors at a time; 5. capture errors earlier; 6. if you are not sure, do not be too strict.
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