...
Note that if setValue() method is used with an Autocomplete widget, the display value will not be updated, as the setValue method only updates the hidden value of Autocomplete widget. However once the form is saved and submitted, it will save the values correctly.
Note that the setValue('<id>.error', "<message>") examples shown above will result in the error messages being shown in the standard error message area.
Defining javascript functions to call before form validation and submission
...