I have a form that works when the form action is set to

 form action="login/login.php"
That works find it displays the error if the details are missing/incorrect and displays the correct page if the correct details are used.

But as soon as I change it to this

 form action="javascript:ajaxpage('login/login.php', 'mainarea');"
It don't work fully it only displays the first error message it hits.

mainarea is a container that holds all the data, the site is AJAX but this seems to be a JavaScript error.