implement javascript validation