what's the deal with blank? function anyway?

is this a better way to check for empty form field inputs than trim and val combined?

You seem to be comparing apples and oranges here. val() is from jQuery and trim() is from JavaScript. #blank? is from Rails (not Ruby). Which one or combination you might use are entirely up to you, and depend on your use-case.

If you want to provide a convenience to your users, and are helping them avoid entering missing or malformed data (but critically, are not relying on this protection to be complete or even present, since JavaScript can be turned off in a browser), then by all means use trim and val and have fun.

If you are going to rely on the data being present before you create a new record in your database, then you had best be using Ruby (and the language extensions Rails provides to it) to do that.

The professional solution would be to use both, so that you can be helpful AND safe.


There’s also jquery-validates.js