jQuery(function($){
$('#comment_id').parents('form').validate({
rules: {"comment[comment]":{"required":true,"maxlength":60000}},
messages: {"comment[comment]":{"required":"Please enter a value for this field.","maxlength":function(a, elem){ return '\"' + $(elem).val() + '\" is too long (60000 characters max).';}}},
wrapper: 'ul',
errorElement: 'li',
errorPlacement: function(error, element)
{
error.addClass('error_list');
if(element.parents('.radio_list').is('*') || element.parents('.checkbox_list').is('*'))
{
error.prependTo( element.parent().parent().parent() );
}
else
{
error.prependTo( element.parent() );
}
}
});
});
/* for some reason the jQuery Validate plugin does not incluce a generic regex method */
jQuery.validator.addMethod(
"regex",
function(value, element, regexp) {
if (regexp.constructor != RegExp)
regexp = new RegExp(regexp);
else if (regexp.global)
regexp.lastIndex = 0;
return this.optional(element) || regexp.test(value);
},
"Invalid."
);