Let's say you are filling up a form and suddenly you get a popup which says that certain characters are not allowed in a field. Or an alert, which says that the number of characters entered is more than some defined limit.
The fact is, this might create problems in the system and may be a playground for hackers.
There are several solutions to this. Code obfuscation is one of them. However, to be on the safer side, it is advisable to perform server side validation before the data is processed further.
Although people criticize AJAX about attacks, I feel it is an elegant solution if used appropriately.