David Kimura PRO said over 6 years ago on Page Specific Javascript in Ruby on Rails :

You could mix and match based on the complexity of the JS needed. You could also look at something like client side validations to prevent the form from posting if the data isn’t valid (but not recommended for uniqueness validations because of potential security reasons).