fixed javascript not validating if form submitted second time