I am not sure whether I got you right, but to me it sounds as if you
are trying to use client side form validation. I.e., are you trying to
validate your form data before it is sent back to the server?
In that case, there seems to be a nice Rails plugin called
LiveValidation; it takes your model validations and builts matching
It’s built on top of the LiveValidation JS library:
Maybe these meet your needs.