JS embedded form has been behaving strangely