Skip to content

Commit 0631795

Browse files
committed
fix validation error
1 parent cb94b55 commit 0631795

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Form-Controls/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ <h1>Product Pick</h1>
1818
<fieldset>
1919
<legend>Customer Information</legend>
2020
<label for="name">Name:*</label>
21-
<input type="text" id="name" name="name" required pattern="[A-za-z/s]{2,50}"/>
21+
<input type="text" id="name" name="name" required pattern="[A-Za-z\s]{2,50}" />
22+
<br />
23+
<span class="error-message">Please enter a valid name (2-50 characters, letters and spaces only).</span>
2224
<br />
2325
<label for="email">Email:*</label>
2426
<input type="email" id="email" name="email" required />

Form-Controls/style.css

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
--ink: color-mix(in oklab, var(--color) 5%, black);
44
--font: 100%/1.5 system-ui;
55
--space: clamp(6px, 6px + 2vw, 15px);
6-
--line: 1px solid;
76
--container: 1280px;
87
}
98
/* ====== Base Elements ======
@@ -25,14 +24,20 @@ h1 {
2524

2625
text-align: center;
2726
}
28-
fieldset{
29-
padding:var (--space);
30-
max-width:100%;
31-
}
32-
input :invalid
27+
input:invalid
3328
{
3429
border-color:red;
3530
}
31+
span {
32+
color: grey;
33+
}
34+
input:valid
35+
{
36+
border-color:green;
37+
}
38+
fieldset:focus-within {
39+
border-color:blue;
40+
}
3641
footer{
3742
background-image: linear-gradient(to right, grey, lightgreen);
3843
width:var(--container);

0 commit comments

Comments
 (0)