Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 4 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
22 changes: 11 additions & 11 deletions Form-Controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ Do not write a form action for this project.

Let's write out our testable criteria:

- [ ] I have used HTML and CSS only.
- [x] I have used HTML and CSS only.

### HTML

- [ ] My form is semantic html.
- [ ] All inputs have associated labels.
- [ ] My Lighthouse Accessibility score is 100.
- [ ] I require a valid name. I have defined a valid name as a text string of two characters or more.
- [ ] I require a valid email.
- [ ] I require one colour from a defined set of 3 colours.
- [ ] I require one size from a defined set of 6 sizes.
- [ ] I require one date from a constrained date range.
- [x] My form is semantic html.
- [x] All inputs have associated labels.
- [x] My Lighthouse Accessibility score is 100.
- [x] I require a valid name. I have defined a valid name as a text string of two characters or more.
- [x] I require a valid email.
- [x] I require one colour from a defined set of 3 colours.
- [x] I require one size from a defined set of 6 sizes.
- [x] I require one date from a constrained date range.

### CSS

- [ ] I show which element is focused.
- [ ] My Lighthouse Accessibility score is 100.
- [x] I show which element is focused.
- [x] My Lighthouse Accessibility score is 100.

## Extension Task

Expand Down
63 changes: 59 additions & 4 deletions Form-Controls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,74 @@
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="index.js"></script> -->
<header>
<h1>Product Pick</h1>
</header>
<main>
<form>
<!-- write your html here-->
<!-- try writing out the requirements first-->
<form name="choosing" method="post" class="field-wrap">
<div class="formbox">
<div>
<label for="name">Name</label>
<input type="text" id="name" name="name" required>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the validation criteria for names in the requirements?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just force to write name but if we want we can write a Pattern for the name
pattern="^[A-Za-z]+(([',. -][A-Za-z ])?[A-Za-z])$"

</div>
<div>
<label for="family" >Family</label>
<input type="text" id="family" name="family" required>
</div>
<div>
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
</div>
<div class="address">
<div>
<label for="address">Address</label>
<input type="text" id="address" name="address" required>
</div>
<div class="postcode">
<label for="postcode">Postcode</label>
<input type="text" id="postcode" name="postcode" required>
</div>
Comment on lines +32 to +39

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this information? If so, how should we validate it (e.g. Postcodes have a certain format)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for send Item we need address but for validate I can add patern on inpute for the check
Post code:pattern="^[A-Z]{1,2}\d[A-Z\d]? \d[A-Z]{2}$" like this

<div>
<label for="t-shirtColor">Choose T-shirt Color</label>
<select name="t-shirtColor" id="t-shirtColor" required>
<option value="">-- Select a Color --</option>
<option value="Blue">Blue</option>
<option value="Black">Black</option>
<option value="Purple">Purple</option>
</select>
</div>
<div>
<label for="t-shirtSize">Choose T-shirt Size</label>
<select name="t-shirtSize" id="t-shirtSize" required>
<option value="">-- Select a Size --</option>
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
</select>

</div>
<div>
<label for="date">Choose Delivery Date:</label>

<input type="date" name="date" id="date" min="31/10/2024" max="31/11/2024" required="">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that the date picker allows dates outside of your bounds here. Any ideas why?

Also, what does required="" do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for notice this i relisede I wrote wrong format it should be yyyy/mm/dd.
required is force to write here but I can set what is format what i want inside of "" this.

</div>
</div>


<button type="submit" id="choose">Submit</button>
</div>
</form>


</main>
<footer>
<!-- change to your name-->
<h2>By HOMEWORK SOLUTION</h2>
<h2>By Armin Nouri</h2>
</footer>
</body>

Expand Down
33 changes: 33 additions & 0 deletions Form-Controls/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// $(document).ready(function () {
// // Event listener for input and textarea fields
// $('form').find('input, textarea').on('keyup blur focus', function (e) {
// var $this = $(this),
// label = $this.prev('label');

// switch (e.type) {
// case 'keyup':
// if ($this.val() === '') {
// label.removeClass('active highlight');
// } else {
// label.addClass('active highlight');
// }
// break;

// case 'blur':
// if ($this.val() === '') {
// label.removeClass('active highlight');
// } else {
// label.removeClass('highlight');
// }
// break;

// case 'focus':
// if ($this.val() === '') {
// label.removeClass('highlight');
// } else if ($this.val() !== '') {
// label.addClass('highlight');
// }
// break;
// }
// });
// })
151 changes: 151 additions & 0 deletions Form-Controls/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/* Basic Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* Body styling */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #FBFDFC; /* Light background */
color: #333; /* Dark text for readability */
}

/* Container */
.container {
width: 80%;
margin: 0 auto;
overflow: hidden;
}

/* Header styling */
header {
background: #c4c4c4; /* Darker gray for better visibility */
color: #1a1a1a; /* Darker text for contrast */
padding: 20px 0;
text-align: center;
}

/* Main content */
main {
padding: 20px;
background: #ffffff; /* White for main content */
margin-top: 20px;
border-radius: 5px;
}

form {
display: flex;
}

.field-wrap {
margin-bottom: 40px;
}

.formbox {
display: flex;
flex-direction: column;
gap: 20px; /* Better than justify-content for consistent spacing */
padding: 20px; /* Adds spacing inside the container */
border: 1px solid #ccc; /* Optional: adds a border for a defined area */
border-radius: 5px; /* Rounded corners for a more modern look */
background-color: #f0f0f0; /* Optional: background color for better visibility */
width: fit-content;
}

input, select, button {
color: #1a1a1a; /* Darker text for better contrast */
background-color: #ffffff; /* White background for form controls */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that your form control backgrounds are not white -- what is your intention?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not haveing really good realtions with colors but for take 100% accebility i should do it.

border: 1px solid #999999; /* Darker border for better definition */
}

button {
background-color: #0056b3; /* Darker blue button */
color: #ffffff; /* White text for contrast */
width: 70%;
margin-left: 50px;
padding: 10px; /* Adjust padding for better size */
height: auto; /* Use auto to ensure the button is responsive */
border: none; /* Remove border for cleaner look */
border-radius: 5px; /* Rounded corners for button */
}

.address {
display: flex;
gap: 10px; /* Creates space between address fields */
align-items: center; /* Align items vertically in the middle */
flex-wrap: wrap; /* Allows wrapping on smaller screens */
}

.postcode {
flex: 1; /* Flex-grow:1 allows this to take up available space */
min-width: 100px; /* Optional: sets a minimum width to maintain layout */
}

/* Label styling */
label {
transform: translateY(6px);
transition: all 0.5s ease;
pointer-events: none;
font-size: 18px;
padding-left: 10px;
color: #1a1a1a; /* Darker label text for better contrast */
}

input, textarea {
font-size: 22px;
display: block;
width: 100%;
padding: 5px 10px;
background: none;
border: 1px solid #888888; /* Darker border for better visibility */
color: #1a1a1a; /* Darker text color for better readability */
transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

form {
padding: 40px;
max-width: 600px;
margin: 40px auto;
border: 4px solid #f9e3c2; /* Light border */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Slight shadow for depth */
}

input:focus, textarea:focus {
outline: 0;
border-color: #1ab188; /* Highlight border on focus */
}

/* Footer */
footer {
background: #c4c4c4; /* Darker gray for footer */
color: #1a1a1a; /* Dark text for contrast */
text-align: center;
padding: 10px 0;
margin-top: 20px;
}
button#choose {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way we can target the submit button of the form without using its ID?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think there is just one button so we can but I couldn't remeber why I did this ?:)

background-color: #0056b3; /* Darker blue for better contrast */
color: #ffffff; /* White text for readability */
width: 70%;
margin-left: 50px;
padding: 10px; /* Ensures a comfortable touch target */
height: auto; /* Responsive height */
border: none; /* Removes default border */
border-radius: 5px; /* Rounded corners */
font-size: 16px; /* Readable font size */
transition: background-color 0.3s, border-color 0.3s; /* Smooth transition effects */
}

/* Optional: Add hover effect */
button#choose:hover {
background-color: #004494; /* Even darker blue on hover for better visibility */
}

/* Optional: Add focus effect for accessibility */
button#choose:focus {
outline: 2px solid #1ab188; /* Green outline for focus state */
outline-offset: 2px; /* Space between outline and button */
}