Uncaught TypeError: c is undefined

How to manage Uncaught TypeError: c is undefined.

If I add script inside form it will work but inside separate Javascript it will not be detected an error message area.

Form = {
init: function() {
  var $ = jQuery;
  var parsleyConfig = {
  errorsContainer: function(pEle) {
    var $err = pEle.$element.siblings('.error_message');
   }
  }

  var $parsley = $('#parsley-form').parsley(parsleyConfig);
 }
}

It will work above form:

<script>
var $ = jQuery;
$(function()
 {

  var parsleyConfig = {
  errorsContainer: function(pEle) {
    var $err = pEle.$element.siblings('.error_message');
   }
  }

  var $parsley = $('#parsley-form').parsley(parsleyConfig);
 }
)
</script>

What’s the error? Where exactly in the source HTML are you putting it (if not in the form area?) At the top of the source file, or the bottom? :slight_smile:

I’m putting at the top of form and it works. If I set initiation it will be placed inside a separate file (JS).

Due to demo testing, it is showing also additional Javascript error which I should remove.

Maybe this is an issue as it prevents separate file to make it functional. But is is strange that other JS scripts will work without an issue.

Where do you call the js file from in your html?

The scripts should be at the end of the html otherwise the elements will not exist before the js is run and an error may occur.

<script src="my.js"></script>
</body>
</html>

I have solved an error. It was misleading for me. It is not an issue with the Javascript but HTML shows me an error with the pure HTML. When I solved HTML issue (form was outside DIV element) it is working without any issue. Thank you for all help as HTML is also an issue.

1 Like