Refactor out submit handlers in login/register javascript files.