Learn Web Development From Scratch
0️⃣ HTML / CSS
1️⃣ JavaScript
2️⃣ React / Vue / Angular
3️⃣ Node.js / Express
4️⃣ REST API
5️⃣ SQL / NoSQL Databases
6️⃣ UI / UX Design
7️⃣ Git / GitHub
Admin: @love_data
Post #3533
4.54K
- ❤ 5
- 👏 1
WE @webdevcoursefree
Showing posts older than #3534 · Back to latest
function Welcome() {
return <h1>Hello User</h1>;
}
<Welcome />
function Header() {
return <h1>My Website</h1>;
}
function Welcome(props) {
return <h1>Hello {props.name}</h1>;
}
<Welcome name="Deepak" />
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>{count}</p>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}
function MyName() {
return <h2>My name is Deepak</h2>;
}
export default MyName;
function Welcome(props) {
return <h2>Hello {props.name}</h2>;
}
export default Welcome;
<Welcome name="Deepak" />
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return <h2>Count: {count}</h2>;
}
export default Counter;
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<h2>Count: {count}</h2>
<button onClick={() => setCount(count + 1)}>
Increase
</button>
</div>
);
}
export default Counter;
import MyName from "./MyName";
import Welcome from "./Welcome";
import Counter from "./Counter";
function App() {
return (
<div>
<MyName />
<Welcome name="Deepak" />
<Counter />
</div>
);
}
export default App;
const cors = require('cors');
app.use(cors());project/📝 Step 1: HTML (Form UI)
├── index.html
├── style.css
└── script.js
<h2>Signup Form</h2>🎨 Step 2: Basic CSS (Optional Styling)
<form id="form">
<input type="text" id="username" placeholder="Username">
<input type="text" id="email" placeholder="Email">
<input type="password" id="password" placeholder="Password">
<p id="error" style="color:red;"></p>
<p id="success" style="color:green;"></p>
<button type="submit">Register</button>
</form>
<script src="script.js"></script>
body { font-family: Arial; padding: 40px; }
input { padding: 10px; width: 250px; display:block; margin-bottom:10px; }
button { padding: 10px 20px; cursor: pointer; }
⚡ Step 3: JavaScript Logicconst form = document.getElementById("form");
const error = document.getElementById("error");
const success = document.getElementById("success");
form.addEventListener("submit", (e) => {
e.preventDefault();
const username = document.getElementById("username").value.trim();
const email = document.getElementById("email").value.trim();
const password = document.getElementById("password").value.trim();
error.textContent = "";
success.textContent = "";
if (username === "") {
error.textContent = "Username is required";
return;
}
if (!email.includes("@")) {
error.textContent = "Enter valid email";
return;
}
if (password.length < 6) {
error.textContent = "Password must be at least 6 characters";
return;
}
success.textContent = "Registration successful!";
});
✅ What This Project Teachesstyle attribute.<style> tag inside the <head> section of an HTML document.<link> tag and is written in a separate .css file.margin: auto; property. For example:.center {
width: 50%;
margin: auto;
}*)element).class)#id)[attribute]):pseudo-class)::pseudo-element)absolute, relative, fixed, and sticky positioning in CSS.relative: The element is positioned relative to its normal position.absolute: The element is positioned relative to its nearest positioned ancestor or the initial containing block if none exists.fixed: The element is positioned relative to the viewport and does not move when the page is scrolled.sticky: The element is treated as relative until a given offset position is met in the viewport, then it behaves as fixed.display: flex; on a container element.em, and rem. Media queries adjust styles based on the viewport's width, height, and other characteristics. For example:@media (max-width: 600px) {
.container {
width: 100%;
}
}@keyframes rule to define the animation and the animation property to apply it to an element. For example:@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
.element {
animation: example 5s infinite;
}<form id="form">
<input type="text" id="username">
<button>Submit</button>
</form>
const form = document.getElementById("form");
form.addEventListener("submit", (e) => {
const username = document.getElementById("username").value;
if (username === "") {
e.preventDefault();
alert("Username is required");
}
});const email = document.getElementById("email").value;
if (!email.includes("@")) {
alert("Enter valid email");
}if (password.length < 6) {
alert("Password must be at least 6 characters");
}<input type="text" id="username">
<p id="error"></p>
if (username === "") {
error.textContent = "Username required";
}<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>
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;
}
});