Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CSS-Form-Handling/form-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions CSS-Form-Handling/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS-Only Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="form-container">
<h1>CSS-Only Account Signup</h1>
<p class="subtitle">An interactive form validation — zero JavaScript, pure CSS.</p>

<!-- Success Message (Hidden by default) -->
<div class="success-popup" id="success">
<div class="popup-content">
<h2>🎉 Account Created Successfully!</h2>
<p>Welcome! Your account has been created and you're ready to get started.</p>
<a href="./index.html" class="close-btn">Create Another Account</a>
</div>
</div>

<form class="validation-form" action="#success" method="GET">
<!-- Name Field -->
<div class="input-group">
<label for="name">Full Name <span class="required">*</span></label>
<input
type="text"
id="name"
name="name"
required
minlength="2"
pattern="[A-Z][A-Za-z\s]{2,}"
placeholder="Enter your full name"
/>
<div class="error-message">Please enter a valid name (first letter need to be capital, letters only, minimum 2 letters required)</div>
</div>

<!-- Email Field -->
<div class="input-group">
<label for="email">Email Address <span class="required">*</span></label>
<input
type="email"
id="email"
name="email"
pattern="^[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$"
required
placeholder="Enter your email address"
/>

<div class="error-message">Please enter a valid email address</div>
</div>

<!-- Phone Field -->
<div class="input-group">
<label for="phone">Phone Number <span class="required">*</span></label>
<input
type="tel"
id="phone"
name="phone"
required
pattern="^(\d{3}-\d{3}-\d{4}|\d{10})$"
placeholder="435-837-2847"
/>
<div class="error-message">Please enter a valid phone number in the format XXX-XXX-XXXX</div>
</div>

<!-- Password Field -->
<div class="input-group">
<label for="password">Password <span class="required">*</span></label>
<input
type="password"
id="password"
name="password"
required
minlength="6"
placeholder="Enter your password"
/>
<div class="error-message">Password must be at least 6 characters long</div>
</div>

<!-- Terms Checkbox -->
<div class="checkbox-group">
<input type="checkbox" id="terms" name="terms" required>
<label for="terms">
I agree to the <a href="#" target="_blank">Terms and Conditions</a> <span class="required">*</span>
</label>
</div>

<!-- Submit Button -->
<button type="submit" class="submit-button">
Create Account
</button>
</form>
</div>
</div>
</body>
</html>
137 changes: 137 additions & 0 deletions CSS-Form-Handling/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
font-family: 'Inter', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}

.container { width: 100%; max-width: 500px; }

.form-container {
background: white;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

h1 { text-align: center; color: #374151; font-size: 28px; font-weight: 600; margin-bottom: 8px; }
.subtitle { text-align: center; color: #6b7280; margin-bottom: 32px; font-size: 16px; }

.validation-form { display: flex; flex-direction: column; gap: 20px; }
.input-group, .checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-group { flex-direction: row; align-items: flex-start; gap: 12px; }

label { font-weight: 500; color: #374151; font-size: 14px; }
.required { color: #dc2626; }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"] {
padding: 12px 16px;
border: 2px solid #d1d5db;
border-radius: 8px;
font-size: 16px;
transition: all 0.2s ease;
outline: none;
}

input[type="checkbox"] { width: 18px; height: 18px; accent-color: #4f46e5; cursor: pointer; margin-top: 2px; }
.checkbox-group label { cursor: pointer; line-height: 1.5; }

/* Focus and Validation States */
input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
input:valid:not(:placeholder-shown) { border-color: #059669; }
input:invalid:not(:focus):not(:placeholder-shown) { border-color: #dc2626; }

/* Error Messages - only show when field is invalid and touched */
.error-message {
color: #dc2626;
font-size: 14px;
font-weight: 500;
display: none;
margin-top: 4px;
}

.input-group input:invalid:not(:focus):not(:placeholder-shown) + .error-message { display: block; }

/* Submit Button */
.submit-button {
background: #4f46e5;
color: white;
border: none;
padding: 14px 24px;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
margin-top: 12px;
}

.submit-button:hover { background: #3730a3; transform: translateY(-1px); }
.submit-button:active { transform: translateY(0); }

/* Disable submit when form invalid */
.validation-form:invalid .submit-button {
background: #9ca3af;
cursor: not-allowed;
transform: none;
}

/* Success Popup */
.success-popup {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: none;
align-items: center;
justify-content: center;
z-index: 1000;
}

.success-popup:target { display: flex; }

.popup-content {
background: white;
padding: 40px;
border-radius: 12px;
text-align: center;
max-width: 400px;
margin: 20px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.popup-content h2 { color: #059669; margin-bottom: 16px; font-size: 24px; }
.popup-content p { color: #374151; line-height: 1.6; margin-bottom: 20px; }

.close-btn {
display: inline-block;
background: #4f46e5;
color: white;
padding: 10px 20px;
border-radius: 6px;
text-decoration: none;
font-weight: 500;
transition: all 0.2s ease;
}

.close-btn:hover { background: #3730a3; transform: translateY(-1px); }

/* Links */
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 640px) {
.form-container { padding: 24px; margin: 10px; }
h1 { font-size: 24px; }
.subtitle { font-size: 14px; }
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Please be aware that the demos may exhibit significant accessibility issues, suc
- [City Animation Footer](#city-animation-footer)
- [Carousel Effect](#carousel-effect)
- [Counter of Checked Checkboxes](#counter-of-checked-check-boxes)
- [CSS Form Handling](#css-form-handling)
- [Download_buttons](#Download_buttons)
- [Dog Box Animation](#dog-box-animation)
- [Dropdown Menu](#dropdown-menu)
Expand Down Expand Up @@ -633,6 +634,20 @@ Please be aware that the demos may exhibit significant accessibility issues, suc

---

## <a id="css-form-handling"></a>CSS Form Handling

[<img src="images/form-preview.png" height="230" title="CSS Form Handling">](CSS-Form-Handling/)

**[⬆ back to top](#quick-links)**

## <a id="Download_buttons"></a>Download_buttons

[<img src="images/Download_buttons.png" title="Download_buttons">](https://codepen.io/Shail-Sharma-the-animator/pen/rNXYMGx)

**[⬆ back to top](#quick-links)**

---

## <a id="Download_buttons"></a>Download buttons

[<img src="images/Download_buttons.png" title="Download_buttons">](https://codepen.io/Shail-Sharma-the-animator/pen/rNXYMGx)
Expand Down
Binary file added images/form-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.