-
Notifications
You must be signed in to change notification settings - Fork 20
w1 homework #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jwan0190
wants to merge
3
commits into
distinctioncoding:main
Choose a base branch
from
jwan0190:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
w1 homework #26
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| //define elements of html | ||
| const form = document.getElementById('sign-up-form'); | ||
| const nameField = document.getElementById('name'); | ||
| const phoneField = document.getElementById('phone'); | ||
| const duluxField = document.getElementById('dulux'); | ||
| const submitBtn = document.getElementById('form-submit-btn'); | ||
|
|
||
| //validate form fields | ||
| const isName = (str) => { | ||
| const nameValue = nameField.value.trim(); | ||
| if (nameValue === '') { | ||
| throw('Name cannot be empty'); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| //validate phone number | ||
| const isPhone = (str) => { | ||
| const phoneValue = phoneField.value.trim(); | ||
| const phoneRegex = /^[0-9]{10}$/; // Example: 10 digit number | ||
| if (!phoneRegex.test(phoneValue)) { | ||
| throw('Phone number must be a 10 digit number'); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| //validate dulux account | ||
| const isDulux = (str) => { | ||
| const duluxValue = duluxField.value.trim(); | ||
| if (duluxValue === '') { | ||
| throw('Dulux account cannot be empty'); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| //handle form submission | ||
| form.addEventListener('submit', function(event) { | ||
| event.preventDefault(); //prevent default form submission | ||
|
|
||
| try { | ||
| //validate each field | ||
| isName(nameField.value); | ||
| isPhone(phoneField.value); | ||
| isDulux(duluxField.value); | ||
|
|
||
| //if all validations pass, submit the form (here we just log a message) | ||
| console.log('Form submitted successfully!'); | ||
| form.submit(); | ||
| } catch (error) { | ||
| //display error message | ||
| alert(error); | ||
| } | ||
| }); | ||
|
|
||
| console.log('Form validation script loaded.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link rel="stylesheet" href="styles.css"> | ||
| <script type="module" src="form.js"></script> | ||
|
|
||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <main class="container" style="width: 100vw; height: 100vh;"> | ||
| <section class="first"> | ||
| <div class="title-group"> | ||
| <h1>Welcometo Paint Quote System</h1> | ||
| <p>Consequat adispic...........swhua sghy wuatf drcf gvbh cjkauiywtfr dsfwaghjkm wa. dhwyaufda adgtywand syuwaza. gyswa gyswaba y8dwa huswa. swahygtdwa uisywa. atd at6wa </p> | ||
| </div> | ||
|
|
||
| </section> | ||
|
|
||
| <section class="second"> | ||
| <div class="card"> | ||
| <form id="sign-up-form" action="/submit" method="post"> | ||
| <header class="title"> | ||
| <h1 class="signup">Sign Up</h1> | ||
| <p class='center'>Enter details to create your account</p> | ||
| </header> | ||
|
|
||
| <div class="field"> | ||
| <label for="name">Your name</label> | ||
| <input type="text" name="name" id="name" placeholder="Enter your name"> | ||
| </div> | ||
| <div class="field"> | ||
| <label for="phone">Phone number</label> | ||
| <input type="tel" name="name" id="phone" placeholder="Enter your phone number"> | ||
| </div> | ||
| <div class="field"> | ||
| <label for="dulux">Dulux Account</label> | ||
| <input type="text" name="dulux" id="dulux" placeholder="Enter your Dulux account"> | ||
| </div> | ||
|
|
||
| <button class="primary">Sign up</button> | ||
| <footer> | ||
| <p class="center">Already have an account? <a href="https://www.google.com">Sign in</a></p> | ||
| </footer> | ||
| </form> | ||
| </div> | ||
| </section> | ||
|
|
||
| </main> | ||
| </body> | ||
| </html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| body{ | ||
| margin:0px; | ||
| } | ||
|
|
||
| .container{ | ||
| width:100vw; | ||
| height:100vh; | ||
| background-image:url("./img.png"); | ||
| background-repeat: no-repeat; | ||
| background-position: center; | ||
| background-size: cover; | ||
| display:flex; | ||
| justify-content:space-between; | ||
| } | ||
|
|
||
|
|
||
| .container > section.first{ | ||
| width:45%; | ||
| max-width:700px; | ||
| height:100%; | ||
| display:flex; | ||
| justify-content:center; | ||
| align-items:center; | ||
| } | ||
|
|
||
| .container > section.second{ | ||
| width:45%; | ||
| height:100%; | ||
| display:flex; | ||
| justify-content:center; | ||
| align-items:center; | ||
| } | ||
|
|
||
| section.first > .title-group{ | ||
| width:80%; | ||
| } | ||
|
|
||
| .title-group > h1{ | ||
| text-align:center; | ||
| color:rgb(43,82,107); | ||
| } | ||
|
|
||
| .title-group > p{ | ||
| margin:8px; | ||
| color:rgb(43,82,107); | ||
| } | ||
|
|
||
| .title-group > h1::after { | ||
| content: ""; | ||
| display: block; | ||
| width: 100%; | ||
| height: 3px; | ||
| background:rgb(43,82,107); | ||
| margin-top: 8px; | ||
| } | ||
jwan0190 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| form > div { | ||
| width:100%; | ||
| height:fit-content; | ||
| display:flex; | ||
| flex-direction:column; | ||
| justify-content:center; | ||
| align-items:center; | ||
| } | ||
|
|
||
| form > .title > h1 + p { | ||
| margin:0px; | ||
| } | ||
|
|
||
| button.primary{ | ||
| background-color:rgb(51,117,170); | ||
| width:80%; | ||
| height:40px; | ||
| border-radius:5px; | ||
| border:none; | ||
| color:white; | ||
| } | ||
|
|
||
| form label{ | ||
| display:block; | ||
| width:80%; | ||
| color:rgb(141,141,141); | ||
| } | ||
|
|
||
|
|
||
| form input{ | ||
| display:block; | ||
| width:80%; | ||
| height:40px; | ||
| color:rgb(141,141,141); | ||
| } | ||
|
|
||
| p.center{ | ||
| text-align:center; | ||
| color:rgb(141,141,141); | ||
| } | ||
|
|
||
| form h1{ | ||
| text-align:center; | ||
| } | ||
|
|
||
| div.card{ | ||
| background-color:white; | ||
| border-radius:10px; | ||
| width:80%; | ||
| height:fit-content; | ||
| box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); | ||
| overflow:hidden; | ||
| } | ||
|
|
||
| form{ | ||
| display:flex; | ||
| flex-direction:column; | ||
| gap: 10px; | ||
| align-items:center; | ||
| height:100%; | ||
| } | ||
|
|
||
|
|
||
| @media (max-width: 768px) { | ||
| .container{ | ||
| flex-direction:column; | ||
| align-items:center; | ||
| justify-content:center; | ||
| } | ||
|
|
||
| .container > section.first,.container>section.second{ | ||
| width:95vw; | ||
| } | ||
|
|
||
| .container > section.first{ | ||
| height:30vh; | ||
| } | ||
|
|
||
| .container>section.second{ | ||
| height:70vh; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.