jQuery(function($){
$('#sf_guard_user_id').parents('form').validate({
rules: {"sf_guard_user[first_name]":{"required":true,"maxlength":255},"sf_guard_user[last_name]":{"required":true,"maxlength":255},"sf_guard_user[email_address]":{"required":true,"maxlength":255},"sf_guard_user[username]":{"required":true,"maxlength":128},"sf_guard_user[password]":{"required":true,"maxlength":128},"sf_guard_user[password_again]":{"maxlength":128}},
messages: {"sf_guard_user[first_name]":{"required":"Required.","maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (255 characters max).';}},"sf_guard_user[last_name]":{"required":"Required.","maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (255 characters max).';}},"sf_guard_user[email_address]":{"required":"Required.","maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (255 characters max).';}},"sf_guard_user[username]":{"required":"Required.","maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (128 characters max).';}},"sf_guard_user[password]":{"required":"Required.","maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (128 characters max).';}},"sf_guard_user[password_again]":{"maxlength":function(a, elem){ return '\\\"' + $(elem).val() + '\\\" is too long (128 characters max).';}}},
onkeyup: false,
wrapper: 'ul class=error_list',
errorElement: 'li',
errorPlacement: function(error, element)
{
if(element.parents('.radio_list').is('*') || element.parents('.checkbox_list').is('*'))
{
error.prependTo( element.parent().parent().parent() );
}
else
{
error.prependTo( element.parent() );
}
//, submitHandler: function(form) {}
}
});
$('#sf_guard_user_email_address').rules('add', {"remote":"\/sfJqueryFormVal\/remote\/BeesAwardsRegisterForm\/sfValidatorDoctrineUnique","messages":{"remote":"This email is already registered.
If you forgot your password, you may use the 'Forgot your password?' link on the login page<\/a>."}});
$('#sf_guard_user_username').rules('add', {"remote":"\/sfJqueryFormVal\/remote\/BeesAwardsRegisterForm\/sfValidatorDoctrineUnique","messages":{"remote":"An object with the same \"%column%\" already exist."}});
});
/* 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."
);