'Javascript Form
I have a quick question. I am learning how to make a registration form using javascript and found this link very helpful.
http://www.w3resource.com/javascript/form/javascript-sample-registration-form-validation.php
I understand everything in the code except for this line in the html page...
<body onload="document.registration.userid.focus();">
I know it is saying that when the page is loaded run this javascript function, but I don't understand what each part does. If someone could please explain this to me I would greatly appreciate it.
Solution 1:[1]
This is the direct way to "walk the DOM." Starting from the top (document) you then select successive elements by name. The form's name is registration and the element's name is
userid. The call to .focus() places the cursor in that field so that the user can begin typing immediately when the page loads instead of manually highlighting the field.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathletics |
