fix javascript validation of object before submit