You should use something similar to
CGI::Ex::Validate which handles validation nicely on the perl side or the javascript side - but doesn't require the javascript side.
On another note - AJAX form validation can be somewhat silly. Essentially you are hitting the server to check the information, to see if you can submit the form, which if submitted will hit the server, which will necessarily need to recheck the information.
The form validation needs to do as much as possible without hitting the server - which is what CGI::Ex::Validate does.
my @a=qw(random brilliant braindead); print $a[rand(@a)];