Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Duplication check of Email in Firebase database in JavaScript

I'm completely new to firebase. I'm creating a basic contact form for my application and connected that to the firebase database. I don't have any authentication for my application. . I have set all the rules to True . I want to prevent duplication, if there exists email in database I want to display an error message.

Below is my code which I have tried

var config = {
  apiKey: "AIzaSyDA3u4bIIYHHTcB8u11NxtRVh9MOWe0jJQ",
  authDomain: "wable-bb8b1.firebaseapp.com",
  databaseURL: "https://wable-bb8b1-default-rtdb.firebaseio.com",
  projectId: "wable-bb8b1",
  storageBucket: "wable-bb8b1.appspot.com",
  messagingSenderId: "739938703423",
};
firebase.initializeApp(config);


// Reference messages collection
var messagesRef = firebase.database().ref('Email');

// Listen for form submit
document.getElementById('contactForm').addEventListener('submit', submitForm);


// Submit form
function submitForm(e){
  e.preventDefault();

  //Get value
  var email = getInputVal('email');

  // Save message
  saveMessage(email);

  // Show alert
  document.querySelector('.alert').style.display = 'block';

  // Hide alert after 3 seconds
  setTimeout(function(){
    document.querySelector('.alert').style.display = 'none';
  },3000);

  // Clear form
  document.getElementById('contactForm').reset();
}

// Function to get form value
function getInputVal(id){
  return document.getElementById(id).value;
}

// Save message to firebase
function saveMessage(email){
  var newMessageRef = messagesRef.push();
  newMessageRef.set({
    email: email
  });
}  

I looked for some solutions but it didn't work

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!