AnsweredAssumed Answered

Unable to get form to validate when I click submit button.

Question asked by csergent08 Champion on Apr 29, 2015
Latest reply on Apr 30, 2015 by csergent08

I have three  fields in a form call feedbackModal. They are all required and mark withed required, but when I click submit, I receive the following error: Uncaught TypeError: Cannot read property '0' of null for the following lines of code:

 

// submit or cancel request and hide modal 

        query("#feedbackModal .btn").on("click", function (e) { // e is defined but never used.

            // NOTE: this is not implemented in sample app 

            if (document.getElementById("#feedbackModal")[0].checkValidity()) {

                query("#feedbackModal").modal("hide");

            }

            else {

                //show errors

                return false;

            }

          

        });

 

 

and this one:

 

on(dom.byId("btnFeedback"), "click", function () {

        sendEmail();

    });

 

 

    function sendEmail() {

       

        if (document.getElementById("#feedbackModal")[0].checkValidity()) {

            var link = "mailto:" + document.getElementById("eMail").value

            + "&subject=" + escape(document.getElementById('subject').value)

            + "&body=" + escape(document.getElementById('comment').value)

            ;

        }

        else {

            //show errors

            return false;

            alert("All fields are required!");

 

 

        }

      

 

 

       

    }

Outcomes