Skip to main content

formulário de login com problema [closed]

Estou desenvolvendo um formulário de login, e esta dando um erro no último passo..

Uncaught ReferenceError: form is not defined
at login (index.js:9:8)
at HTMLButtonElement.onclick (login.html:272:79)
login @ index.js:9
onclick @ login.html:272

function validateFields(){
    toggleButtonsDisable();
    toggleEmailErrors();
   }

   function login() {
     firebase.auth().signInWithEmailAndPassword(
       form.email().value, form.password().value
     ).then(response => {
       window.location.href = "/index.html";
     }).catch(error => {
       console.log('error', error)
     });

  

   }

  function isEmailValid() {
    const email = document.getElementById("email").value;
    if (!email) {
      return false;
    }
    return validateEmail(email);

  }

  function toggleEmailErrors() {
    const email = document.getElementById('email').value;
    if (!email) {
      document.getElementById('email-required-error').style.display = "block";
    } else {
      document.getElementById('email-required-error').style.display = "none";
    }

  }

  function toggleButtonsDisable() {

      const emailValid = isEmailValid();
      document.getElementById('recover-password-button').disabled = !emailValid;

      const password = isPasswordValid();
      document.getElementById('login-button').disabled = !emailValid || !passwordValid;

  }

  function isPasswordValid() {
    const password = document.getElementById('password').value;
    if (!password) {
      return false;
    }
    return true;
  }

  function validateEmail(email) {
    return /\S+@\S+\.\S+/.test(email);
  }
</head>

  <body>

    <img class="banner" src="../img/quem-somos.png" alt="">

    <header class="header">
      <button class="header__btnMenu" style="display: none;"><i class="fa-solid fa-align-justify fa-2x"></i> <span class="sr-only">Menu</button>
      <nav class="header__nav">
        <ul>
          <li><a href="../index.html">Início</a></li>
          <li><a href="../secundarias/Quem-somos.html">Quem Somos</a></li>
          <li><a href="../secundarias/Curso.html">Curso</a></li>
          <li><a href="../secundarias/Convalidação-de-diploma.html">Convalidação de Diploma</a></li>
          <li><a href="../secundarias/Psicoterapeutas-trinicos-credenciados.html">Psicoterapeutas Trínicos Credenciados</a></li>
          <li><a href="../secundarias/Terapia-online.html">Terapia Online</a></li>
          <li><a href="../secundarias/Livros-ebooks.html">Livros/E-books</a></li>
          <li><a href="../secundarias/Contatos.html">Contatos</a></li>
        </ul>
      </nav>
    </header>

    <div id="login-container">
      <h1 class="h1">Login</h1>
      <form>
        <label for="email">E-mail</label>
        <input type="email" name="email" placeholder="Digite seu email" autocomplete="off"/>
        <div class="error">Email Inválido</div>
        <div class="error" id="email-required-error">Email Obrigatório</div>
        <label for="password">Senha</label>
        <input type="password" name="password" placeholder="Digite sua senha"/>
        <div class="error">Senha Inválida</div>
        <div class="error">Senha Obrigatória</div>
        <button type="button" class="btn" id="login-button" onclick="login()">Entrar</button>
      </form>





    </div>

  </body>

    <script src="../js/menu.js"></script>
    <script src="../js/main.js"></script>
    <script src="../js/index.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.9.4/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.9.4/firebase-auth-compat.js"></script>
    <script>
    const firebaseConfig = {
          apiKey: "AIzaSyAfVQmZHjackadr36QeUuXGoDCE12rRthY",
          authDomain: "login-7ba66.firebaseapp.com",
          projectId: "login-7ba66",
          storageBucket: "login-7ba66.appspot.com",
          messagingSenderId: "60367460532",
          appId: "1:60367460532:web:75192848133ccca5141fe1"
        };
        firebase.initializeApp(firebaseConfig);

        console.log('antes');
        firebase.auth().signInWithEmailAndPassword("andremeinerz@hotmail.com", "123456").then(response => {
          console.log('success', response)
        }).catch(error => {
          console.log('error', error)
        });
        console.log('depois')


      
    </script>

APARECE ISSO NO CONSOLE. Alguém pode me ajudar.. segui os passos de um vídeo, e o dele da certo..

Via Active questions tagged javascript - Stack Overflow https://ift.tt/xvRB10Q

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype