Home > Web Front-end > JS Tutorial > Things to pay attention to in Javascript form validation_javascript tips

Things to pay attention to in Javascript form validation_javascript tips

WBOY
Release: 2016-05-16 16:34:59
Original
1191 people have browsed it

Javascript form programming:

1. How to find form elements:

1.var oForm=document.getElementById("Form1");

2.var oForm=document.forms[Form1]//Search by name;

2. Common characteristics of form fields:

disabled: This attribute is used to indicate whether a form control is available;

form attribute: This attribute returns the form containing fields;

blur(): This method causes the form field to lose focus;

focus(): This method causes the form field to gain focus;

blur event: This event occurs when the form field loses focus, and then the onblur event handler is executed;

focus event: This event occurs when the form field gains focus, and then the onfocus event handler is executed;

Three: Form submission, reset

sumbit: oForm sumbit();

reset: oForm reset();

4. Get the value of the text box:

length otext.value.length;

Five: Add element nodes, text nodes, delete elements

creatElement, creatTextNode, remove;

6: Check the value of the check box: select

Seven: Best practices for form validation:

Must be helpful to users;

Don’t be annoying;

Use HTML functionality instead of Javascript whenever possible

Show all errors at once;

Catch errors early;

Don’t be too strict if you are not sure;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template