Skip to content

Commit d00e325

Browse files
Add regex validation for username input
1 parent efd979c commit d00e325

1 file changed

Lines changed: 86 additions & 85 deletions

File tree

Form-Controls/index.html

Lines changed: 86 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,88 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6-
<title>My form exercise</title>
7-
<meta name="description" content="" />
8-
<meta name="viewport" content="width=device-width, initial-scale=1" />
9-
<link rel="stylesheet" href="style.css">
10-
11-
</head>
12-
<body>
13-
<header>
14-
<h1>Product T-shirts</h1>
15-
</header>
16-
<main>
17-
<form>
18-
<!-- write your html here-->
19-
20-
<!-- 1. What is the customer's name? I must collect this data and ensure it contains at least two non-space characters. -->
21-
22-
<label for="username">Name</label>
23-
<input type="text" id="username" minlength="2" required autocomplete="name">
24-
25-
<!-- 2. What is the customer's email? I must make sure the email is valid. Email addresses follow a consistent pattern. -->
26-
27-
<label for="email">Email</label>
28-
<input type="email" id="email" required autocomplete="email">
29-
30-
<!-- 3. What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours? -->
31-
32-
<fieldset>
33-
<legend>Choose a colour</legend>
34-
35-
<label for="red">Red</label>
36-
<input type="radio" id="red" name="colour" value="red" required>
37-
38-
<label for="green">Green</label>
39-
<input type="radio" id="green" name="colour" value="green">
40-
41-
<label for="white">White</label>
42-
<input type="radio" id="white" name="colour" value="white">
43-
44-
45-
</fieldset>
46-
47-
<!-- 4. What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL -->
48-
49-
<fieldset>
50-
<legend>Choose a size</legend>
51-
52-
<label for="xs">XS</label>
53-
<input type="radio" id="xs" name="size" value="xs" required>
54-
55-
<label for="s">S</label>
56-
<input type="radio" id="s" name="size" value="s" required>
57-
58-
<label for="m">M</label>
59-
<input type="radio" id="m" name="size" value="m" required>
60-
61-
<label for="l">L</label>
62-
<input type="radio" id="l" name="size" value="l" required>
63-
64-
<label for="xl">XL</label>
65-
<input type="radio" id="xl" name="size" value="xl" required>
66-
67-
<label for="xxl">XXL</label>
68-
<input type="radio" id="xxl" name="size" value="xxl" required>
69-
70-
71-
</fieldset>
72-
73-
<button type="submit">Submit</button>
74-
75-
76-
77-
<!--
78-
try writing out the requirements first as comments
79-
this will also help you fill in your PR message later-->
80-
</form>
81-
</main>
82-
<footer>
83-
<!-- change to your name-->
84-
<p>Made with love by Abid Akhtar</p>
85-
</footer>
86-
</body>
87-
</html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<title>My form exercise</title>
8+
<meta name="description" content="" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
<link rel="stylesheet" href="style.css">
11+
12+
</head>
13+
14+
<body>
15+
<header>
16+
<h1>Product T-shirts</h1>
17+
</header>
18+
<main>
19+
<form>
20+
21+
22+
<!-- 1. What is the customer's name? I must collect this data and ensure it contains at least two non-space characters. -->
23+
24+
<label for="username">Name</label>
25+
<input type="text" id="username" pattern=".*\S.*\S.*" required autocomplete="name">
26+
27+
<!-- 2. What is the customer's email? I must make sure the email is valid. Email addresses follow a consistent pattern. -->
28+
29+
<label for="email">Email</label>
30+
<input type="email" id="email" required autocomplete="email">
31+
32+
<!-- 3. What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours? -->
33+
34+
<fieldset>
35+
<legend>Choose a colour</legend>
36+
37+
<label for="red">Red</label>
38+
<input type="radio" id="red" name="colour" value="red" required>
39+
40+
<label for="green">Green</label>
41+
<input type="radio" id="green" name="colour" value="green">
42+
43+
<label for="white">White</label>
44+
<input type="radio" id="white" name="colour" value="white">
45+
46+
47+
</fieldset>
48+
49+
<!-- 4. What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL -->
50+
51+
<fieldset>
52+
<legend>Choose a size</legend>
53+
54+
<label for="xs">XS</label>
55+
<input type="radio" id="xs" name="size" value="xs" required>
56+
57+
<label for="s">S</label>
58+
<input type="radio" id="s" name="size" value="s" required>
59+
60+
<label for="m">M</label>
61+
<input type="radio" id="m" name="size" value="m" required>
62+
63+
<label for="l">L</label>
64+
<input type="radio" id="l" name="size" value="l" required>
65+
66+
<label for="xl">XL</label>
67+
<input type="radio" id="xl" name="size" value="xl" required>
68+
69+
<label for="xxl">XXL</label>
70+
<input type="radio" id="xxl" name="size" value="xxl" required>
71+
72+
73+
</fieldset>
74+
75+
<button type="submit">Submit</button>
76+
77+
78+
79+
80+
</form>
81+
</main>
82+
<footer>
83+
84+
<p>Made with love by Abid Akhtar</p>
85+
</footer>
86+
</body>
87+
88+
</html>

0 commit comments

Comments
 (0)