Home > Net >  Javascript form checking without innerhtml response
Javascript form checking without innerhtml response

Time:02-21

Hi im just starting to learn web development but I can't seem to find why my innerHTML won't appear on my page can someone help me ? I need to show these error messages if the fields are left empty but I can't seem to get it working for some reason :/

JS:

// B. email

const frmOrder = document.querySelector('#frmOrder');
const inpEmail = frmOrder.querySelector('#inpEmail');
const msgEmail = frmOrder.querySelector('.message');
// B. Dropdown
const selMeasure = frmOrder.querySelector('#selMeasure');
const msgMeasure = frmOrder.querySelector('.selMeasure .message');

//B. Checking
frmOrder.setAttribute('novalidate', 'novalidate');
frmOrder.addEventListener('sumbit', function (e) { 
    e.preventDefault();
    let numErrors = 0 ;
    
    msgEmail.innerHTML = '' ;
    msgMeasure.innerHTML = '' ;


if (inpEmail.value == '' ) {
    msgEmail.innerHTML = "please fill in ur email!";
    numErrors  ;
}
if (selMeasure.value == '' ) {
    msgMeasure.innerHTML = "please fill in ur Measurement!";
    numErrors  
}
if (numErrors == 0) {
    frmOrder.sumbit();
    lblMessage.innerHTML = `Het formulier is correct ingevuld`;
   

}
});

CodePudding user response:

There are syntax errors in your code.

Change the word sumbit to submit.

  • Related