Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//The jQuery validate plugin validates on the name attribute,
//which is problematic in Rails because every checkbox
//gets a hidden input with the same name.
//Here's how to validate the checkbox, not the hidden input:
var validate = function(){
$(':input:hidden').attr('name', 'new_name');
rules: {"checkbox": "required"},
messages: {"checkbox": "CHECK ME"},
submitHandler: function(form){
//give the hidden checkbox its name back
//so nothing explodes on the backend
$(':input:hidden').attr('name', 'old_name');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.