I made a form and give some validations on submitting and I also want to give validation of if the email that user use in sign up is already exist or not in firebase database ,for which first I have to get the email child from database ,I already done it .The emails are printing in the console and I give variable to that specific one like
<input type="email" name="mail" id="email" placeholder="Email" />
<p id="emailerr"></p>
ref.on('value', snapshot => {
snapshot.forEach(function (snapChild) {
var fireemail = snapChild.child('email').val();
console.log(fireemail)
})
});
This is on submit function
function onSubmit(e) {
var check
e.preventDefault()
if (email==fireemail){
emailerr.innerHTML='EMAIL ALREADY EXIST'
check=false;
}
if(check==false){
alert("Not submit")}
}else{
writeData(fname, email, pass, my_male, my_female)
location.reload()
alert('Form submitted successfully')
}
The variable fireemail is not recognise by the submit function,it gives undefined and instead of giving error it submits the form in the database
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…