Forms
Forms
1. HTML Forms
The HTML Forms can be used to collect data from the user.
Login/Sign in Form
Registration Form
The HTML
form element can be used to create HTML forms. It is a container that can contain different types of Input elements like Text Fields, Checkboxes, etc.
HTML
1 <form></form>
Note
Enter key while editing any input field in the form, the submit event will be triggered.
2.1 preventDefault
The
submit event.
JAVASCRIPT
3. Event Types
Keyboard Events
Mouse Events
Touch Events
blur
focus
change, etc.
The
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.
5 <script src="https://code.jquery.com/jquery-3.5.1.slim.min.j
6 <script src="https://cdn.jsdelivr.net/npm/[email protected]/d
7 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.
8 </head>
9 <body>
10 <div class="container">
11 <h1 class="form-heading">Add User</h1>
12 <form id="myForm">
13 <div class="mb-3">
14 <label for="name">Name</label>
15 <input type="text" class="form-control" id="name" />
Reset Code Run Code