Skip to content

Commit cfb77a3

Browse files
committed
feat: for validation completed for names and email using pattern attribute.
1 parent 5388ad5 commit cfb77a3

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

Form-Controls/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
<!--{{<objectives>}}>-->
66

7-
- [ ] Interpret requirements and check against a list of criteria
8-
- [ ] Write a valid form
7+
- [ x ] Interpret requirements and check against a list of criteria
8+
- [ x ] Write a valid form
99
- [ ] Test with Devtools
1010
- [ ] Refactor using Devtools
11-
- [ ] Use version control by committing often and pushing regularly to GitHub
12-
- [ ] Develop the habit of writing clean, well-structured, and error-free code
11+
- [ x ] Use version control by committing often and pushing regularly to GitHub
12+
- [ x ] Develop the habit of writing clean, well-structured, and error-free code
1313
<!--{{<objectives>}}>-->
1414

1515
## Task
@@ -22,30 +22,30 @@ Writing that out as a series of questions to ask yourself:
2222

2323
1. What is the customer's name? I must collect this data and ensure it contains at least two non-space characters.
2424
2. What is the customer's email? I must make sure the email is valid. Email addresses follow a consistent pattern.
25-
3. What colour should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours?
25+
3. What color should this T-shirt be? I must provide 3 options. How will I ensure they do not choose other colours?
2626
4. What size does the customer want? I must provide the following 6 options: XS, S, M, L, XL, XXL
2727

2828
All fields are required.
2929
Do not write a form action for this project.
3030

31-
## Acceptnce Criteria
31+
## Acceptance Criteria
3232

3333
### Developers must test their work.
3434

3535
Let's write out our testable criteria. Check each one off as you complete it.
3636

37-
- [ ] I have only used HTML and CSS.
38-
- [ ] I have not used any JavaScript.
37+
- [ x ] I have only used HTML and CSS.
38+
- [ x ] I have not used any JavaScript.
3939

4040
### HTML
4141

42-
- [ ] My form is semantic HTML.
43-
- [ ] All inputs have associated labels.
42+
- [ x ] My form is semantic HTML.
43+
- [ x ] All inputs have associated labels.
4444
- [ ] My Lighthouse Accessibility score is 100.
45-
- [ ] I require a valid name.
46-
- [ ] I require a valid email.
47-
- [ ] I require one colour from a defined set of 3 colours.
48-
- [ ] I require one size from a defined set of 6 sizes.
45+
- [ x ] I require a valid name.
46+
- [ x ] I require a valid email.
47+
- [ x ] I require one color from a defined set of 3 colors.
48+
- [ x ] I require one size from a defined set of 6 sizes.
4949

5050
### Developers must adhere to professional standards.
5151

Form-Controls/index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8" />
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
4+
<meta charset="utf-8"/>
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
66
<title>My form exercise</title>
7-
<meta name="description" content="" />
8-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="description" content=""/>
8+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
99
<link rel="stylesheet" href="main.css">
1010

1111
</head>
@@ -18,7 +18,7 @@ <h1>Product Pick</h1>
1818
<main>
1919
<div class="container">
2020
<form>
21-
<!-- write your html here-->
21+
<!-- write your HTML here-->
2222
<!--
2323
try writing out the requirements first as comments
2424
this will also help you fill in your PR message later-->
@@ -30,14 +30,14 @@ <h1>Product Pick</h1>
3030

3131

3232
<div class="form-group">
33-
<label for="firstname">First Name</label>
33+
<label for="firstname">First Name </label>
3434
<input
3535
type="text"
3636
id="firstname"
3737
name="firstname"
3838
required
39-
pattern=""
40-
title=""
39+
pattern="^[A-Za-z]{2,15}$"
40+
title="first name must be between 2 and 15 characters"
4141
>
4242
</div>
4343

@@ -48,8 +48,8 @@ <h1>Product Pick</h1>
4848
id="lastname"
4949
name="lastname"
5050
required
51-
pattern=""
52-
title="">
51+
pattern="^[A-Za-z]{2,15}$"
52+
title="last name must be between 2 and 15 characters">
5353
</div>
5454

5555
<div class="form-group">
@@ -59,8 +59,8 @@ <h1>Product Pick</h1>
5959
id="email"
6060
name="email"
6161
required
62-
pattern=""
63-
title="">
62+
pattern="^[^\s@]+@[^\s@]\.(com|co\.uk)$"
63+
title="Enter a valid email">
6464
</div>
6565

6666
<div class="form-group">

0 commit comments

Comments
 (0)