Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 year ago

intro signup form

Karim Hussein•270
@karim-abd-hussein
A solution to the Intro component with sign-up form challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What specific areas of your project would you like help with?

here the code that I have use for javascript but I'm not sure if that clean and perfect code **maybe some feedback or tips to follow **

js file

const inputFiled=document.getElementsByTagName("input");
const warningElements=document.getElementsByClassName("warning");
const submitInput=document.querySelector("input[type='submit']");


// this will listen for all warning that has clicked 
// and returned to default
for (let i = 0; i < warningElements.length; i++) {
   const element = warningElements[i]; 

   element.addEventListener('click',() =>{
      element.style.display="none";
      inputFiled[i].style.display="block";


   })
   
}

function checkEmptyFiled(e){

  for (let i = 0; i < inputFiled.length-1; i++) {
   const element = inputFiled[i];

   if(element.value===''){
   e.preventDefault();
      element.style.display="none";
      warningElements[i].style.display="flex";
   }

}  

}

submitInput.addEventListener('click',function(e) {
   checkEmptyFiled(e);

});```
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Karim Hussein's solution.

Join 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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License