window.jQuery = window.$j = jQuery; $j(document).ready(function(){ $j.validator.setDefaults({ }); jQuery.validator.addMethod("notEqual", function(value, element, param) { return this.optional(element) || value !== param; }, "Please choose a value!"); $j('#commentform').validate({ submitHandler: function() { var actionUrl = 'comment.php'; $j.ajax({ type: 'POST', url: actionUrl, data: $j('#commentform').serialize(), success: function(msg){ $j('#commentform').hide(); $j('#newcomment').val(''); $j('#commentslist').append(msg); $j('html, body').animate({ scrollTop: $('#commentslist div:last-child').offset().top }, 'slow'); } }); return false; }, rules: { newcomment: { required: true } }, messages: { newcomment: "Please, enter text" } }); });