-
-
Notifications
You must be signed in to change notification settings - Fork 91
sheffield_ArminNouri_Form controls _Week 2 #210
Changes from 1 commit
bacef79
5078f85
246457e
839a05d
f3dfb6e
a9123e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,19 +9,73 @@ | |
| <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> | ||
| </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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| <div> | ||
| <text for="color">choose T-shirt color</text> | ||
| <select name="t-shirtColor" id="t-shirtColor" required=""> | ||
| <option value="Blue">Blue</option> | ||
| <option value="Black">Black</option> | ||
| <option value="Purple">Purple</option> | ||
| </select> | ||
| </div> | ||
| <div> | ||
| <text for="t-shirtSize">Choose T-shirt Size</text> | ||
| <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> | ||
| <text for="date">Choose Delivery Date:</text> | ||
|
|
||
| <input type="date" name="date" id="date" min="31/10/2024" max="31/11/2024" required=""> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| </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> | ||
|
|
||
|
|
||
| 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; | ||
| } | ||
| }); | ||
| }) |
| 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; | ||
| color: #333; | ||
| } | ||
|
|
||
| /* Container */ | ||
| .container { | ||
| width: 80%; | ||
| margin: 0 auto; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| /* Header styling */ | ||
| header { | ||
| background: #F4EFEB; | ||
| color: #252F31; | ||
| padding: 20px 0; | ||
| text-align: center; | ||
| } | ||
|
|
||
| /* Navigation */ | ||
| nav { | ||
| display: flex; | ||
| justify-content: space-around; | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| nav a { | ||
| color: #fff; | ||
| text-decoration: none; | ||
| padding: 5px 20px; | ||
| } | ||
|
|
||
| nav a:hover { | ||
| background: #3e8c81; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| /* Main content */ | ||
| main { | ||
| padding: 20px; | ||
| background: #fff; | ||
| margin-top: 20px; | ||
| border-radius: 5px; | ||
| } | ||
| form{ | ||
| display: flex; | ||
|
|
||
| } | ||
| .field-wrap { | ||
| position: ; | ||
| 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: #f9f9f9; /* Optional: background color for better visibility */ | ||
| width: fit-content; | ||
| } | ||
|
|
||
| .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 { | ||
| position: absolute; | ||
| transform: translateY(6px); | ||
| color: rgba(0, 0, 0, 0.5); | ||
| transition: all 0.5s ease; | ||
| pointer-events: none; | ||
| font-size: 18px; | ||
| padding-left: 10px; | ||
| } | ||
|
|
||
| /* Required field indicator */ | ||
| label .req { | ||
| margin-left: 15px; /* Changed to better position the asterisk */ | ||
| color: #010202; | ||
| font-size: 14px; /* Adjusted font-size for consistency */ | ||
| } | ||
|
|
||
| /* Label when active (e.g., input is focused) */ | ||
| label.active { | ||
| transform: translateY(-20px); /* Moves label up when active */ | ||
| font-size: 14px; | ||
| } | ||
|
|
||
| /* Hide the required field indicator when the label is active */ | ||
| label.active .req { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| /* Highlight the label when the input is focused */ | ||
| label.highlight { | ||
| color: #150606; | ||
| } | ||
| input, textarea { | ||
| font-size: 22px; | ||
| display: block; | ||
| width: 100%; | ||
| padding: 5px 10px; | ||
| background: none; | ||
| border: 1px solid #a0b3b0; | ||
| color: #a0b3b0; | ||
| transition: border-color 0.25s ease, box-shadow 0.25s ease; | ||
| } | ||
| form { | ||
| /* background-color: #13232f; */ | ||
| padding: 40px; | ||
| max-width: 600px; | ||
| margin: 40px auto; | ||
| border: 4px solid #ffecd2 ; | ||
| box-shadow: 0 4px 10px 4px rgba(#ffecd2); | ||
| } | ||
| input:focus, textarea:focus { | ||
| outline: 0; | ||
| border-color: #1ab188; | ||
| } | ||
|
|
||
|
|
||
| /* Footer */ | ||
| footer { | ||
| background: #F4EFEB; | ||
| color: #252F31; | ||
| text-align: center; | ||
| padding: 10px 0; | ||
| margin-top: 20px; | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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])$"