js func for same subject codes nd required fields