I'm using Rails with the JQuery plugin, and have some really complicated validations for one of my forms that I decided to use JQuery for. For very simplified example, the fields A1, A2, ... A4, B1 - B4, and C1 - C4. Just a few of the rules are:
- if a user inputs any data into A,B, or C, then they MUST input into all four fields.
- if a user inputs any data into A or B, they must also complete the other (B or A).
- no fields's value may differ from it's neighbor by more than 10%
Actually only the average of A, average of B, and average of C are stored in the database / model, so I'm relying totally on client-side JQuery that I wrote to validate (all in application.js). I finally got this working quite smoothly. My rails model is not bothering itself with any of these validations.
The problem is, I need to be able to grab the error messages from Rails, because of i18n ( I need English and Chinese). For example "Field is required" or "Must be a number". I am using i18n successfully with the rest of my app... I just don't know how to use it with JQuery.
Any ideas how to do this, or points in the right direction?
(I should note that I never used JQuery or Javascript before 3 days ago, so I'm a pretty big newb in this area)