validateField function