0

I'm very new to this and I can't figure out whats wrong with my school project. I think maybe my javascript file isn't linked correctly, or maybe the code is just broken?

// }
// Commented out above "}" - Edits must be at least 6 characters
 function repost() { 
       var epost = document.getElementById('epost');
       var repost = document.getElementById('repost');

       if (epost.value != repost.value) { 
           repost.setCustomValidity('Epost adresserna måste matcha.'); 
       } else { 
           // input is valid -- reset the error message 
           repost.setCustomValidity(''); 
      } 
 } 
<!doctype html>
 <html>
  <head>
   <meta charset="utf-8">
   <title>Skapa konto</title>
   <link href="Stilmall.css" rel="stylesheet" type="text/css">
   <script>var __adobewebfontsappname__="dreamweaver"</script>
   <script src="http://use.edgefonts.net/abel:n4:default.js" type="text/javascript"></script>
   <script src="reg.js" type="text/javascript"></script>
  </head>
  <body>
   <div class="form1">
    <form name="form2" id="form3" method="post" onsubmit="return validateForm();" action="tack.html">

     <p class="form_text">
     <input type="text" id="epost" placeholder="E-post" required>
     <input type="text" id="repost" placeholder="Repetera E-post" required oninput="repost(this)">
     </p>

     <p class="form_text">
       <input type="submit" id="sumbit" value="Registrera">
     </p>
    </form>
   </div>
  </body>
 </html>
Jesper
  • 3
  • 3
  • 5
    First, I would remove the character } that you have above your repost function – acarlstein Aug 01 '18 at 21:28
  • 3
    Use developer tools console to find errors in your code (press F12 in the browser) in the snippet you posted you can easily see the error – Calvin Nunes Aug 01 '18 at 21:28
  • 2
    will you include the entire external .js file? also check the path that you have in the src for reg.js – Shreyas Aug 01 '18 at 21:31

1 Answers1

1

Hmm, this is a bit tricky but your id and function name both are "repost", in this situation you will get an error saying repost is not a function and you have to change the name of function or id. this has been discussed here : Why JS function name conflicts with element ID?

Also don't forget to fix the typo in your if condition.

r3zaxd1
  • 697
  • 9
  • 17