Uncaught TypeError: Object .NumCon has no method 'apply'

javascript, jquery

Solution

You're calling your function from inside of the definition line, which is (for some reason) then interpreted as an object.

$('.NumCon').on('keyup', NumCon);​

Solves your problem.

Problem

I want run a jquery code that if number value text input was under of `7`, the result is false. but i get following error: ``` Uncaught TypeError: Object .NumCon has no method 'apply' f.event.dispatch f.event.add.h.handle.i ``` What do i do? Demo: http://jsfiddle.net/FZMsP/ This is my code: ``` <form> <input type="password" name="user_pass" class="NumCon" id="7"> </form> ​ function NumCon() { var result = true; $(this).closest("form").find('.NumCon').each(function () { var size = this.value.length; var NumVal = $(this).attr('id'); if (size <= NumVal) { $(this).css("background", "#ffc4c4"); result = false; }else{ $(this).css("background-color", "#ffffec"); } }); } $('.NumCon').live('keyup', NumCon());​ ```

Original source