'Checking the input text with placeholder

How can I compare the entered text in the array of fields with the text that is in the placeholder? i.e., for example, I have 3 fields and I placed the text inside the placeholder, after clicking on the button, a check is performed if the entered is true with what is written in the placeholder, then the message "Correct value!". I wrote this code, but after clicking the error is displayed: "Object reference not set to an instance of an object". Please tell me how can I fix it?

 foreach (InputField inputField in Input_Number)
        {
            Graphic graphic = gameObject.GetComponent<InputField>().placeholder;
            
            if (inputField.text == ((Text)graphic).text)
            {
                    Debug.LogFormat($"{ball}");
            }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source