Uncaught TypeError: reportValidity[] is not a function

1.8k Views Asked by At

I am working on a form on which on hitting save button after entering the necessary details in it, I am getting the following error:

Uncaught TypeError: e.reportValidity[s] is not a function
    at HTMLButtonElement.<anonymous> 
    at f  (Line#57)
    at HTMLDivElement.f.handle
    at HTMLDivElement.dispatch 


const legalityMethod = function () { 
return 'reportValidity' in document.createElement('input') ? 'reportValidity' : 'checkValidity'; 
}();

Line#57 corresponds to the following while loop;

function validate(form, field) {

    while (m && m--) {

        switch (fields[m]) {

            case 'hello_world':

                form.hello_world.setCustomValidity(config.language['amazing_world']);
                break;
        }
    }

    return form.reportValidity[legalityMethod]();  //line#57
}

Problem Statement:

I am wondering what are the reasons behind this error and how I can get rid of this error.

0

There are 0 best solutions below