Fixed remember inputs value after post, and catch errors in validation

Catching errors is needed if the form items changes between loading the form and sending it

Also did some code formatting changes