What does DOM stand for in JavaScript?
Anonymous Quiz
19%
A. Data Object Model
76%
B. Document Object Model
5%
C. Display Object Method
1%
D. Digital Order Model
❤6
Which method selects a single element by its unique ID?
Anonymous Quiz
3%
A. document.querySelectorAll()
12%
B. document.getElementsByClassName()
82%
C. document.getElementById()
3%
D. document.getElementsByTagName()
❤4
Which method returns ALL elements that match a CSS selector?
Anonymous Quiz
10%
A. document.querySelector()
63%
B. document.querySelectorAll()
10%
C. document.getElementById()
18%
D. document.getElementsByClassName()
❤4
Which property is best for changing only the text of an element?
Anonymous Quiz
27%
A. innerHTML
39%
B. innerText
31%
C. textContent
3%
D. value
❤4
Which method is used to add or remove a CSS class dynamically?
Anonymous Quiz
18%
25%
B. element.setAttribute()
35%
C. element.classList.toggle()
22%
D. element.addClass()
❤4
𝐏𝐚𝐲 𝐀𝐟𝐭𝐞𝐫 𝐏𝐥𝐚𝐜𝐞𝐦𝐞𝐧𝐭 - 𝐆𝐞𝐭 𝐏𝐥𝐚𝐜𝐞𝐝 𝐈𝐧 𝐓𝐨𝐩 𝐌𝐍𝐂'𝐬 😍
Learn Coding From Scratch - Lectures Taught By IIT Alumni
60+ Hiring Drives Every Month
𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬:-
🌟 Trusted by 7500+ Students
🤝 500+ Hiring Partners
💼 Avg. Rs. 7.4 LPA
🚀 41 LPA Highest Package
Eligibility: BTech / BCA / BSc / MCA / MSc
𝐑𝐞𝐠𝐢𝐬𝐭𝐞𝐫 𝐍𝐨𝐰👇 :-
https://pdlink.in/4hO7rWY
Hurry, limited seats available!
Learn Coding From Scratch - Lectures Taught By IIT Alumni
60+ Hiring Drives Every Month
𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬:-
🌟 Trusted by 7500+ Students
🤝 500+ Hiring Partners
💼 Avg. Rs. 7.4 LPA
🚀 41 LPA Highest Package
Eligibility: BTech / BCA / BSc / MCA / MSc
𝐑𝐞𝐠𝐢𝐬𝐭𝐞𝐫 𝐍𝐨𝐰👇 :-
https://pdlink.in/4hO7rWY
Hurry, limited seats available!
❤3👍1
Now, let's move to the the next topic:
🖱️ JavaScript Events
Events are actions performed by the user or the browser.
Examples
• Clicking a button
• Typing in input
• Submitting a form
• Pressing a key
• Page loading
JavaScript listens to these events and responds.
🧠 Why Events Matter
Without events
• No button clicks
• No form submission handling
• No real interactivity
Events = user + JavaScript talking to each other 🤝
🎧 Event Listener Concept
JavaScript listens for an event and runs a function.
Syntax: element.addEventListener("event", function);
🖱️ Click Event
HTML:
<button id="btn">Click Me</button>
JavaScript:
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
console.log("Button clicked");
});
Use cases:
• Toggle theme
• Open modal
• Submit action
⌨️ Input Event
Triggered when user types.
HTML:
<input type="text" id="name" />
JavaScript:
const input = document.getElementById("name");
input.addEventListener("input", () => {
console.log(input.value);
});
Use cases:
• Live validation
• Search suggestions
📤 Submit Event
Used for forms.
HTML:
<form id="myForm"> <input type="email" /> <button>Submit</button>
</form>
JavaScript:
const form = document.getElementById("myForm");
form.addEventListener("submit", (e) => {
e.preventDefault();
console.log("Form submitted");
});
⚠️ preventDefault() stops page reload.
⌨️ Keyboard Events
Common types:
• keydown
• keyup
Example:
document.addEventListener("keydown", (e) => {
console.log(e.key);
});
Use cases:
• Shortcuts
• Game controls
🧩 Event Object
Event object gives details.
Common properties:
• e.target
• e.type
• e.key
btn.addEventListener("click", (e) => {
console.log(e.target);
});
⚠️ Common Beginner Mistakes
• Forgetting preventDefault()
• Using inline HTML events
• Attaching event before DOM loads
• Using wrong event type
🧪 Mini Practice Task
• Add click event to change text
• Show live input value
• Prevent form submission reload
• Detect key press
✅ Mini Practice Task – Solution
🖱️ JavaScript Events
🟦 1️⃣ Add click event to change text
HTML
<h2 id="text">Hello</h2> <button id="btn">Change Text</button>
JavaScript
const text = document.getElementById("text");
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
text.textContent = "Text changed!";
});
✔️ Text updates on button click
🟩 2️⃣ Show live input value
HTML
<input type="text" id="inputBox" /> <p id="output"></p>
JavaScript
const input = document.getElementById("inputBox");
const output = document.getElementById("output");
input.addEventListener("input", () => {
output.textContent = input.value;
});
✔️ Text updates as user types
🟥 3️⃣ Prevent form submission reload
HTML
<form id="myForm"> <input type="email" required /> <button>Submit</button> </form>
JavaScript
const form = document.getElementById("myForm");
form.addEventListener("submit", (e) => {
e.preventDefault();
console.log("Form submitted without reload");
});
✔️ Page does not refresh
⌨️ 4️⃣ Detect key press
JavaScript
document.addEventListener("keydown", (e) => {
console.log("Key pressed:", e.key);
});
✔️ Logs pressed key in console
🧠 What you learned
• Handling click events
• Real-time input tracking
• Form control
• Keyboard event handling
➡️ Double Tap ♥️ For More
🖱️ JavaScript Events
Events are actions performed by the user or the browser.
Examples
• Clicking a button
• Typing in input
• Submitting a form
• Pressing a key
• Page loading
JavaScript listens to these events and responds.
🧠 Why Events Matter
Without events
• No button clicks
• No form submission handling
• No real interactivity
Events = user + JavaScript talking to each other 🤝
🎧 Event Listener Concept
JavaScript listens for an event and runs a function.
Syntax: element.addEventListener("event", function);
🖱️ Click Event
HTML:
<button id="btn">Click Me</button>
JavaScript:
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
console.log("Button clicked");
});
Use cases:
• Toggle theme
• Open modal
• Submit action
⌨️ Input Event
Triggered when user types.
HTML:
<input type="text" id="name" />
JavaScript:
const input = document.getElementById("name");
input.addEventListener("input", () => {
console.log(input.value);
});
Use cases:
• Live validation
• Search suggestions
📤 Submit Event
Used for forms.
HTML:
<form id="myForm"> <input type="email" /> <button>Submit</button>
</form>
JavaScript:
const form = document.getElementById("myForm");
form.addEventListener("submit", (e) => {
e.preventDefault();
console.log("Form submitted");
});
⚠️ preventDefault() stops page reload.
⌨️ Keyboard Events
Common types:
• keydown
• keyup
Example:
document.addEventListener("keydown", (e) => {
console.log(e.key);
});
Use cases:
• Shortcuts
• Game controls
🧩 Event Object
Event object gives details.
Common properties:
• e.target
• e.type
• e.key
btn.addEventListener("click", (e) => {
console.log(e.target);
});
⚠️ Common Beginner Mistakes
• Forgetting preventDefault()
• Using inline HTML events
• Attaching event before DOM loads
• Using wrong event type
🧪 Mini Practice Task
• Add click event to change text
• Show live input value
• Prevent form submission reload
• Detect key press
✅ Mini Practice Task – Solution
🖱️ JavaScript Events
🟦 1️⃣ Add click event to change text
HTML
<h2 id="text">Hello</h2> <button id="btn">Change Text</button>
JavaScript
const text = document.getElementById("text");
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
text.textContent = "Text changed!";
});
✔️ Text updates on button click
🟩 2️⃣ Show live input value
HTML
<input type="text" id="inputBox" /> <p id="output"></p>
JavaScript
const input = document.getElementById("inputBox");
const output = document.getElementById("output");
input.addEventListener("input", () => {
output.textContent = input.value;
});
✔️ Text updates as user types
🟥 3️⃣ Prevent form submission reload
HTML
<form id="myForm"> <input type="email" required /> <button>Submit</button> </form>
JavaScript
const form = document.getElementById("myForm");
form.addEventListener("submit", (e) => {
e.preventDefault();
console.log("Form submitted without reload");
});
✔️ Page does not refresh
⌨️ 4️⃣ Detect key press
JavaScript
document.addEventListener("keydown", (e) => {
console.log("Key pressed:", e.key);
});
✔️ Logs pressed key in console
🧠 What you learned
• Handling click events
• Real-time input tracking
• Form control
• Keyboard event handling
➡️ Double Tap ♥️ For More
❤13
𝟱 𝗙𝗥𝗘𝗘 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻𝘀 𝗧𝗼 𝗠𝗮𝘀𝘁𝗲𝗿 𝗜𝗻 𝟮𝟬𝟮𝟲😍
𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 :- https://pdlink.in/497MMLw
𝗔𝗜 & 𝗠𝗟 :- https://pdlink.in/4bhetTu
𝗖𝗹𝗼𝘂𝗱 𝗖𝗼𝗺𝗽𝘂𝘁𝗶𝗻𝗴:- https://pdlink.in/3LoutZd
𝗖𝘆𝗯𝗲𝗿 𝗦𝗲𝗰𝘂𝗿𝗶𝘁𝘆:- https://pdlink.in/3N9VOyW
𝗢𝘁𝗵𝗲𝗿 𝗧𝗲𝗰𝗵 𝗖𝗼𝘂𝗿𝘀𝗲𝘀:- https://pdlink.in/4qgtrxU
🌟 Level up your career with these top 5 in-demand skills!
𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 :- https://pdlink.in/497MMLw
𝗔𝗜 & 𝗠𝗟 :- https://pdlink.in/4bhetTu
𝗖𝗹𝗼𝘂𝗱 𝗖𝗼𝗺𝗽𝘂𝘁𝗶𝗻𝗴:- https://pdlink.in/3LoutZd
𝗖𝘆𝗯𝗲𝗿 𝗦𝗲𝗰𝘂𝗿𝗶𝘁𝘆:- https://pdlink.in/3N9VOyW
𝗢𝘁𝗵𝗲𝗿 𝗧𝗲𝗰𝗵 𝗖𝗼𝘂𝗿𝘀𝗲𝘀:- https://pdlink.in/4qgtrxU
🌟 Level up your career with these top 5 in-demand skills!
🌐 Complete Roadmap to Become a Web Developer
📂 1. Learn the Basics of the Web
– How the internet works
– What is HTTP/HTTPS, DNS, Hosting, Domain
– Difference between frontend & backend
📂 2. Frontend Development (Client-Side)
∟📌 HTML – Structure of web pages
∟📌 CSS – Styling, Flexbox, Grid, Media Queries
∟📌 JavaScript – DOM Manipulation, Events, ES6+
∟📌 Responsive Design – Mobile-first approach
∟📌 Version Control – Git & GitHub
📂 3. Advanced Frontend
∟📌 JavaScript Frameworks/Libraries – React (recommended), Vue or Angular
∟📌 Package Managers – npm or yarn
∟📌 Build Tools – Webpack, Vite
∟📌 APIs – Fetch, REST API integration
∟📌 Frontend Deployment – Netlify, Vercel
📂 4. Backend Development (Server-Side)
∟📌 Choose a Language – Node.js (JavaScript), Python, PHP, Java, etc.
∟📌 Databases – MongoDB (NoSQL), MySQL/PostgreSQL (SQL)
∟📌 Authentication & Authorization – JWT, OAuth
∟📌 RESTful APIs / GraphQL
∟📌 MVC Architecture
📂 5. Full-Stack Skills
∟📌 MERN Stack – MongoDB, Express, React, Node.js
∟📌 CRUD Operations – Create, Read, Update, Delete
∟📌 State Management – Redux or Context API
∟📌 File Uploads, Payment Integration, Email Services
📂 6. Testing & Optimization
∟📌 Debugging – Chrome DevTools
∟📌 Performance Optimization
∟📌 Unit & Integration Testing – Jest, Cypress
📂 7. Hosting & Deployment
∟📌 Frontend – Netlify, Vercel
∟📌 Backend – Render, Railway, or VPS (e.g. DigitalOcean)
∟📌 CI/CD Basics
📂 8. Build Projects & Portfolio
– Blog App
– E-commerce Site
– Portfolio Website
– Admin Dashboard
📂 9. Keep Learning & Contributing
– Contribute to open-source
– Stay updated with trends
– Practice on platforms like LeetCode or Frontend Mentor
✅ Apply for internships/jobs with a strong GitHub + portfolio!
👍 Tap ❤️ for more!
📂 1. Learn the Basics of the Web
– How the internet works
– What is HTTP/HTTPS, DNS, Hosting, Domain
– Difference between frontend & backend
📂 2. Frontend Development (Client-Side)
∟📌 HTML – Structure of web pages
∟📌 CSS – Styling, Flexbox, Grid, Media Queries
∟📌 JavaScript – DOM Manipulation, Events, ES6+
∟📌 Responsive Design – Mobile-first approach
∟📌 Version Control – Git & GitHub
📂 3. Advanced Frontend
∟📌 JavaScript Frameworks/Libraries – React (recommended), Vue or Angular
∟📌 Package Managers – npm or yarn
∟📌 Build Tools – Webpack, Vite
∟📌 APIs – Fetch, REST API integration
∟📌 Frontend Deployment – Netlify, Vercel
📂 4. Backend Development (Server-Side)
∟📌 Choose a Language – Node.js (JavaScript), Python, PHP, Java, etc.
∟📌 Databases – MongoDB (NoSQL), MySQL/PostgreSQL (SQL)
∟📌 Authentication & Authorization – JWT, OAuth
∟📌 RESTful APIs / GraphQL
∟📌 MVC Architecture
📂 5. Full-Stack Skills
∟📌 MERN Stack – MongoDB, Express, React, Node.js
∟📌 CRUD Operations – Create, Read, Update, Delete
∟📌 State Management – Redux or Context API
∟📌 File Uploads, Payment Integration, Email Services
📂 6. Testing & Optimization
∟📌 Debugging – Chrome DevTools
∟📌 Performance Optimization
∟📌 Unit & Integration Testing – Jest, Cypress
📂 7. Hosting & Deployment
∟📌 Frontend – Netlify, Vercel
∟📌 Backend – Render, Railway, or VPS (e.g. DigitalOcean)
∟📌 CI/CD Basics
📂 8. Build Projects & Portfolio
– Blog App
– E-commerce Site
– Portfolio Website
– Admin Dashboard
📂 9. Keep Learning & Contributing
– Contribute to open-source
– Stay updated with trends
– Practice on platforms like LeetCode or Frontend Mentor
✅ Apply for internships/jobs with a strong GitHub + portfolio!
👍 Tap ❤️ for more!
❤22
🎓 𝐀𝐜𝐜𝐞𝐧𝐭𝐮𝐫𝐞 𝐅𝐑𝐄𝐄 𝐂𝐞𝐫𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐂𝐨𝐮𝐫𝐬𝐞𝐬 😍
Boost your skills with 100% FREE certification courses from Accenture!
📚 FREE Courses Offered:
1️⃣ Data Processing and Visualization
2️⃣ Exploratory Data Analysis
3️⃣ SQL Fundamentals
4️⃣ Python Basics
5️⃣ Acquiring Data
𝐋𝐢𝐧𝐤 👇:-
https://pdlink.in/4qgtrxU
✅ Learn Online | 📜 Get Certified
Boost your skills with 100% FREE certification courses from Accenture!
📚 FREE Courses Offered:
1️⃣ Data Processing and Visualization
2️⃣ Exploratory Data Analysis
3️⃣ SQL Fundamentals
4️⃣ Python Basics
5️⃣ Acquiring Data
𝐋𝐢𝐧𝐤 👇:-
https://pdlink.in/4qgtrxU
✅ Learn Online | 📜 Get Certified
❤3
24 Youtube Channels for Web Developers
✅ Academind
✅ Clever Programmer
✅ Codecourse
✅ Coder Coder
✅ DevTips
✅ DerekBanas
✅ Fireship
✅ FreeCodeCamp
✅ FlorinPop
✅ Google Developers
✅ Joseph Smith
✅ KevinPowell
✅ LearnCode academy
✅ LearnWebCode
✅ LevelUpTuts
✅ Netanel Peles
✅ Programming with Mosh
✅ SteveGriffith
✅ TheNetNinja
✅ TheNewBoston
✅ TraversyMedia
✅ Treehouse
✅ WebDevSimplified
✅ Codewithharry
✅ Academind
✅ Clever Programmer
✅ Codecourse
✅ Coder Coder
✅ DevTips
✅ DerekBanas
✅ Fireship
✅ FreeCodeCamp
✅ FlorinPop
✅ Google Developers
✅ Joseph Smith
✅ KevinPowell
✅ LearnCode academy
✅ LearnWebCode
✅ LevelUpTuts
✅ Netanel Peles
✅ Programming with Mosh
✅ SteveGriffith
✅ TheNetNinja
✅ TheNewBoston
✅ TraversyMedia
✅ Treehouse
✅ WebDevSimplified
✅ Codewithharry
❤29👍5
𝗔𝗜 𝗙𝗥𝗘𝗘 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲 🔥
Learn Artificial Intelligence without spending a single rupee.
📚 Learn Future-Ready Skills
🎓 Earn a Recognized Certificate
💡 Build Real-World Projects
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗡𝗼𝘄 👇:-
https://pdlink.in/4bhetTu
Enroll Today for Free & Get Certified 🎓
Learn Artificial Intelligence without spending a single rupee.
📚 Learn Future-Ready Skills
🎓 Earn a Recognized Certificate
💡 Build Real-World Projects
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗡𝗼𝘄 👇:-
https://pdlink.in/4bhetTu
Enroll Today for Free & Get Certified 🎓
Which method is used to attach an event listener in JavaScript?
Anonymous Quiz
8%
A. element.addEvent()
8%
B. element.attachEvent()
80%
C. element.addEventListener()
3%
D. element.listen()
❤1
What does e.preventDefault() do in a form submit event?
Anonymous Quiz
19%
A. Stops JavaScript execution
60%
B. Prevents page reload
7%
C. Deletes form data
14%
D. Stops event bubbling
❤2
Which event is triggered when a user types inside an input field?
Anonymous Quiz
17%
A. click
26%
B. change
43%
C. input
15%
D. keypress
❤1
Which event is best used to detect when a key is pressed down?
Anonymous Quiz
47%
A. keydown
4%
B. keyup
40%
C. keypress
8%
D. input
❤2
What does e.target represent inside an event handler?
Anonymous Quiz
9%
A. The browser window
19%
B. The event type
68%
C. The element that triggered the event
4%
D. The parent element
❤2
𝗜𝗜𝗧 𝗥𝗼𝗼𝗿𝗸𝗲𝗲 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗶𝗻 𝗗𝗮𝘁𝗮 𝗦𝗰𝗶𝗲𝗻𝗰𝗲 𝗮𝗻𝗱 𝗔𝗜 😍
Placement Assistance With 5000+ companies.
✅ Open to everyone
✅ 100% Online | 6 Months
✅ Industry-ready curriculum
✅ Taught By IIT Roorkee Professors
🔥 Companies are actively hiring candidates with Data Science & AI skills.
⏳ Deadline: 15th Feb 2026
𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗡𝗼𝘄 👇 :-
https://pdlink.in/49UZfkX
✅ HurryUp...Limited seats only
Placement Assistance With 5000+ companies.
✅ Open to everyone
✅ 100% Online | 6 Months
✅ Industry-ready curriculum
✅ Taught By IIT Roorkee Professors
🔥 Companies are actively hiring candidates with Data Science & AI skills.
⏳ Deadline: 15th Feb 2026
𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗡𝗼𝘄 👇 :-
https://pdlink.in/49UZfkX
✅ HurryUp...Limited seats only
❤1
Master Javanoscript :
The JavaScript Tree 👇
|
|── Variables
| ├── var
| ├── let
| └── const
|
|── Data Types
| ├── String
| ├── Number
| ├── Boolean
| ├── Object
| ├── Array
| ├── Null
| └── Undefined
|
|── Operators
| ├── Arithmetic
| ├── Assignment
| ├── Comparison
| ├── Logical
| ├── Unary
| └── Ternary (Conditional)
||── Control Flow
| ├── if statement
| ├── else statement
| ├── else if statement
| ├── switch statement
| ├── for loop
| ├── while loop
| └── do-while loop
|
|── Functions
| ├── Function declaration
| ├── Function expression
| ├── Arrow function
| └── IIFE (Immediately Invoked Function Expression)
|
|── Scope
| ├── Global scope
| ├── Local scope
| ├── Block scope
| └── Lexical scope
||── Arrays
| ├── Array methods
| | ├── push()
| | ├── pop()
| | ├── shift()
| | ├── unshift()
| | ├── splice()
| | ├── slice()
| | └── concat()
| └── Array iteration
| ├── forEach()
| ├── map()
| ├── filter()
| └── reduce()|
|── Objects
| ├── Object properties
| | ├── Dot notation
| | └── Bracket notation
| ├── Object methods
| | ├── Object.keys()
| | ├── Object.values()
| | └── Object.entries()
| └── Object destructuring
||── Promises
| ├── Promise states
| | ├── Pending
| | ├── Fulfilled
| | └── Rejected
| ├── Promise methods
| | ├── then()
| | ├── catch()
| | └── finally()
| └── Promise.all()
|
|── Asynchronous JavaScript
| ├── Callbacks
| ├── Promises
| └── Async/Await
|
|── Error Handling
| ├── try...catch statement
| └── throw statement
|
|── JSON (JavaScript Object Notation)
||── Modules
| ├── import
| └── export
|
|── DOM Manipulation
| ├── Selecting elements
| ├── Modifying elements
| └── Creating elements
|
|── Events
| ├── Event listeners
| ├── Event propagation
| └── Event delegation
|
|── AJAX (Asynchronous JavaScript and XML)
|
|── Fetch API
||── ES6+ Features
| ├── Template literals
| ├── Destructuring assignment
| ├── Spread/rest operator
| ├── Arrow functions
| ├── Classes
| ├── let and const
| ├── Default parameters
| ├── Modules
| └── Promises
|
|── Web APIs
| ├── Local Storage
| ├── Session Storage
| └── Web Storage API
|
|── Libraries and Frameworks
| ├── React
| ├── Angular
| └── Vue.js
||── Debugging
| ├── Console.log()
| ├── Breakpoints
| └── DevTools
|
|── Others
| ├── Closures
| ├── Callbacks
| ├── Prototypes
| ├── this keyword
| ├── Hoisting
| └── Strict mode
|
| END __
The JavaScript Tree 👇
|
|── Variables
| ├── var
| ├── let
| └── const
|
|── Data Types
| ├── String
| ├── Number
| ├── Boolean
| ├── Object
| ├── Array
| ├── Null
| └── Undefined
|
|── Operators
| ├── Arithmetic
| ├── Assignment
| ├── Comparison
| ├── Logical
| ├── Unary
| └── Ternary (Conditional)
||── Control Flow
| ├── if statement
| ├── else statement
| ├── else if statement
| ├── switch statement
| ├── for loop
| ├── while loop
| └── do-while loop
|
|── Functions
| ├── Function declaration
| ├── Function expression
| ├── Arrow function
| └── IIFE (Immediately Invoked Function Expression)
|
|── Scope
| ├── Global scope
| ├── Local scope
| ├── Block scope
| └── Lexical scope
||── Arrays
| ├── Array methods
| | ├── push()
| | ├── pop()
| | ├── shift()
| | ├── unshift()
| | ├── splice()
| | ├── slice()
| | └── concat()
| └── Array iteration
| ├── forEach()
| ├── map()
| ├── filter()
| └── reduce()|
|── Objects
| ├── Object properties
| | ├── Dot notation
| | └── Bracket notation
| ├── Object methods
| | ├── Object.keys()
| | ├── Object.values()
| | └── Object.entries()
| └── Object destructuring
||── Promises
| ├── Promise states
| | ├── Pending
| | ├── Fulfilled
| | └── Rejected
| ├── Promise methods
| | ├── then()
| | ├── catch()
| | └── finally()
| └── Promise.all()
|
|── Asynchronous JavaScript
| ├── Callbacks
| ├── Promises
| └── Async/Await
|
|── Error Handling
| ├── try...catch statement
| └── throw statement
|
|── JSON (JavaScript Object Notation)
||── Modules
| ├── import
| └── export
|
|── DOM Manipulation
| ├── Selecting elements
| ├── Modifying elements
| └── Creating elements
|
|── Events
| ├── Event listeners
| ├── Event propagation
| └── Event delegation
|
|── AJAX (Asynchronous JavaScript and XML)
|
|── Fetch API
||── ES6+ Features
| ├── Template literals
| ├── Destructuring assignment
| ├── Spread/rest operator
| ├── Arrow functions
| ├── Classes
| ├── let and const
| ├── Default parameters
| ├── Modules
| └── Promises
|
|── Web APIs
| ├── Local Storage
| ├── Session Storage
| └── Web Storage API
|
|── Libraries and Frameworks
| ├── React
| ├── Angular
| └── Vue.js
||── Debugging
| ├── Console.log()
| ├── Breakpoints
| └── DevTools
|
|── Others
| ├── Closures
| ├── Callbacks
| ├── Prototypes
| ├── this keyword
| ├── Hoisting
| └── Strict mode
|
| END __
❤13🔥2🎉2
✅ Form Validation using JavaScript
Form validation checks user input before submission.
🧠 Why Form Validation Matters
Without validation
• Empty forms get submitted
• Wrong emails stored
• Bad data in database
Real examples
• Email format check
• Password rules
• Required fields
🔍 Types of Form Validation
🔹 1. HTML Validation (Built-in)
Browser handles validation automatically.
Example <input type="email" required>
✔️ Checks empty field
✔️ Checks email format
🔹 2. JavaScript Validation (Custom Logic)
You control validation rules.
Used for
• Password strength
• Custom messages
• Complex conditions
📤 Basic Form Validation Flow
1️⃣ User submits form
2️⃣ JavaScript checks input
3️⃣ If invalid → show error
4️⃣ If valid → submit form
✍️ Check Empty Input
HTML
JavaScript
✔️ Stops submission if empty
📧 Email Validation Example
Check using pattern.
Real projects use regular expressions.
🔐 Password Length Validation
🎨 Show Error Message in UI (Better Practice)
HTML
JavaScript
✔️ Better than alert
✔️ User-friendly
⚠️ Common Beginner Mistakes
• Forgetting preventDefault()
• Using only alerts
• No user feedback
• Weak validation rules
✅ Best Practices
• Validate on both client and server
• Show clear error messages
• Use simple rules first
• Give instant feedback
🧪 Mini Practice Task
• Validate username is not empty
• Check email contains @
• Ensure password length ≥ 6
• Show error message on screen
✅ Mini Practice Task Solution – Try it yourself first
This solution covers all 4 tasks:
✔ Username not empty
✔ Email contains @
✔ Password length ≥ 6
✔ Show error message on screen
📝 HTML
⚡ JavaScript
✅ What this code does
• Stops form submission if input is invalid
• Shows error message on screen
• Validates step by step
• Clears old errors automatically
🧠 Key Learning
• Use preventDefault() to stop submission
• Use .trim() to remove extra spaces
• Show errors in UI instead of alerts
• Validate fields one by one
Double Tap ♥️ For More
Form validation checks user input before submission.
🧠 Why Form Validation Matters
Without validation
• Empty forms get submitted
• Wrong emails stored
• Bad data in database
Real examples
• Email format check
• Password rules
• Required fields
🔍 Types of Form Validation
🔹 1. HTML Validation (Built-in)
Browser handles validation automatically.
Example <input type="email" required>
✔️ Checks empty field
✔️ Checks email format
🔹 2. JavaScript Validation (Custom Logic)
You control validation rules.
Used for
• Password strength
• Custom messages
• Complex conditions
📤 Basic Form Validation Flow
1️⃣ User submits form
2️⃣ JavaScript checks input
3️⃣ If invalid → show error
4️⃣ If valid → submit form
✍️ Check Empty Input
HTML
<form id="form">
<input type="text" id="username">
<button>Submit</button>
</form>
JavaScript
const form = document.getElementById("form");
form.addEventListener("submit", (e) => {
const username = document.getElementById("username").value;
if (username === "") {
e.preventDefault();
alert("Username is required");
}
});✔️ Stops submission if empty
📧 Email Validation Example
Check using pattern.
const email = document.getElementById("email").value;
if (!email.includes("@")) {
alert("Enter valid email");
}Real projects use regular expressions.
🔐 Password Length Validation
if (password.length < 6) {
alert("Password must be at least 6 characters");
}🎨 Show Error Message in UI (Better Practice)
HTML
<input type="text" id="username">
<p id="error"></p>
JavaScript
if (username === "") {
error.textContent = "Username required";
}✔️ Better than alert
✔️ User-friendly
⚠️ Common Beginner Mistakes
• Forgetting preventDefault()
• Using only alerts
• No user feedback
• Weak validation rules
✅ Best Practices
• Validate on both client and server
• Show clear error messages
• Use simple rules first
• Give instant feedback
🧪 Mini Practice Task
• Validate username is not empty
• Check email contains @
• Ensure password length ≥ 6
• Show error message on screen
✅ Mini Practice Task Solution – Try it yourself first
This solution covers all 4 tasks:
✔ Username not empty
✔ Email contains @
✔ Password length ≥ 6
✔ Show error message on screen
📝 HTML
<form id="form">
<input type="text" id="username" placeholder="Enter username">
<input type="text" id="email" placeholder="Enter email">
<input type="password" id="password" placeholder="Enter password">
<p id="error" style="color: red;"></p>
<button type="submit">Submit</button>
</form>
⚡ JavaScript
const form = document.getElementById("form");
const error = document.getElementById("error");
form.addEventListener("submit", (e) => {
const username = document.getElementById("username").value.trim();
const email = document.getElementById("email").value.trim();
const password = document.getElementById("password").value.trim();
error.textContent = ""; // clear previous errors
// Username validation
if (username === "") {
e.preventDefault();
error.textContent = "Username is required";
return;
}
// Email validation
if (!email.includes("@")) {
e.preventDefault();
error.textContent = "Enter a valid email";
return;
}
// Password validation
if (password.length < 6) {
e.preventDefault();
error.textContent = "Password must be at least 6 characters";
return;
}
});✅ What this code does
• Stops form submission if input is invalid
• Shows error message on screen
• Validates step by step
• Clears old errors automatically
🧠 Key Learning
• Use preventDefault() to stop submission
• Use .trim() to remove extra spaces
• Show errors in UI instead of alerts
• Validate fields one by one
Double Tap ♥️ For More
❤19👍3
📈 𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 𝗙𝗥𝗘𝗘 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲😍
Data Analytics is one of the most in-demand skills in today’s job market 💻
✅ Beginner Friendly
✅ Industry-Relevant Curriculum
✅ Certification Included
✅ 100% Online
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:-
https://pdlink.in/497MMLw
🎯 Don’t miss this opportunity to build high-demand skills!
Data Analytics is one of the most in-demand skills in today’s job market 💻
✅ Beginner Friendly
✅ Industry-Relevant Curriculum
✅ Certification Included
✅ 100% Online
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:-
https://pdlink.in/497MMLw
🎯 Don’t miss this opportunity to build high-demand skills!
❤1