Implement client side form validation - part 2

This is the second part of #48 :+1: Fixed a couple of bugs and made some code optimization.