
Design comparison
Solution retrospective
simple form with javaScript validation, I used js for validity rather than using built-in attributes where in element input like required and pattern
Community feedback
- @shadowbanksPosted about 2 months ago
Hello mohamedsec,
Congrats on completing this challenge. 🥳 Awesome work! I have a few suggestions that can help improve your page:
- Centering your card
Currently, the card isn't centered on the screen. To achieve this, you can use Flexbox on thebody
element to center it both vertically and horizontally. You can add this in your media query for Desktop:
body{ min-height: 100vh; display: flex; justify-content: center; align-items: center; }
This will center the
main
nicely.- Adjust the Width for mobile
In yourmain.container
I'd recommend adjusting the style to:
main.container{ color: var(--DarkSlateGrey); width: 100%; height: 100%; }
the
position: relative
isn't necessary here, usingwidth: 100%
instead ofmax-width
andmin-width
will ensure that the container takes up the full width on mobile screens.- Image Adjustments
For yourpicture
tag, I'd suggest themedia
query to(max-width:700px)
instead of(max-width:600px)
because you're using700px
as breakpoint for desktop. This ensure better image scaling. Also, consider tweaking the image's height a little to have more height.
Side Note: If you notice a vertical scroll bar, it might be due to the height given to.content
. I'd suggest checking this property and adjusting/removing it if necessary to avoid any unwanted overflow. - Validation with js
- Email input type
Currently, email input only accepts emails that end with.com
, It's better to allow all valid email formats unless you have a specific reason for restricting this. - Real-time Email Validation
Instead of waiting for the user to submit the form, I recommend validating the email input in real-time to improve user experience. This way, users will know if there's an issue with their input right away.
You can achieve this by breaking up the current
loginForm.addEventListener
and create avalidateInput()
function like this:const validateInput = () => { const formData = new FormData(loginForm).entries(); const {email} = Object.fromEntries(formData); const isvalid = emailValidation(email); if (isvalid === "valid"){ displayEerror.style.visibility ="hidden"; formRreg.style.visibility = "hidden"; formSucc.style.visibility = "visible"; } if (isvalid === "invalid"){ displayEerror.style.visibility ="visible"; emailInput.classList.add("errorstyle"); } }
Then, add an event listener to the
#email
input (emailInput
)emailInput.addEventListener('input', (e) => { validateInput(); }
Additionally, update the submit event listener like this:
loginForm.addEventListener('submit',(e)=>{ e.preventDefault(); validateInput(); }
These adjustments will improve the user experience.
I hope you find these suggestions helpful, Happy coding!!! :))
Marked as helpful0@mohamedsecPosted about 2 months ago@shadowbanks Thank you Williams for the helpful comments
1 - Centering your card
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord