Bug in Drupal 7.x.
For example, page contains at least two different forms. If submit one of them and validation fails I will recieve this forms with same element IDs.
If I use AJAX I may got an unexpected behavior, because jQuery thinks that I have no duplicates in DOM. It takes first element with needed ID and process it using AJAX.
But needed ajax element might be second in the DOM, and AJAX was processed wrong element.
To test this you should enable ajax register and contact modules. Put login block into the second sidebar, then logout and go to /contact page. When you get there, just submit contact form. No data should be filled (you should get a validation error).
Then open any web developer tool (I tested in firebug) and search for #edit-name or #edit-submit element. You'll find it in contact form and in the loggin form. Then try to submit contact form again and you will see that this button was processed with AJAX.
Also I've got a solution: When element was not validated in drupal_process_form function
drupal_static_reset('drupal_html_id'); shouldn't be called, because it breaks correct ID's count.
Patch that solves that problem is attached.
User interface changes
PASSED: [[SimpleTest]]: [MySQL] 39,588 pass(es).
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch form_validate_1.patch. Unable to apply patch. See the log in the details link for more information.
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch form_validate_0.patch. Unable to apply patch. See the log in the details link for more information.
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in form_validate.patch.