How do I change an InputFields color in OnChangeValue()?

I am trying to use OnChangeValue() for an InputField to change the color of the field when the user has entered an invalid value but has not yet pressed enter. I change the ColorBlock inputField.colors and then called Rebuild() but the new colors are not used. I have tried all values for CanvasUpdate enum. What should I be calling instead of Rebuild()?

public void OnValueChangedValue(string val) {
		int valI = 0;
		if (!int.TryParse(val, out valI)) {
			valI = 0;
		}
		if (valI > currentMaxValue) {
			regValueField.colors = invalidColors;
		} else {
			regValueField.colors = validColor;
		}
		regValueField.Rebuild(CanvasUpdate.PreRender);
	}

Perhaps this will help you. I used not the OnValueChanged method, but the normal Update:

void Update () 
{
       if(inputField.text == "wrong" && inputField.isFocused)
        {
            inputField.image.color = Color.red;
        }
        else
        {
            inputField.image.color = Color.white;
        }
}

A bit of an outdated post, but there is a better answer in my opinion. I use GetComponent and it handles transitions fine.

inputfield.GetComponent<Image>().color = new Color(1f,1f,1f)