converted javascript validation to php