Question by
siaknimarkanthony · Feb 24, 2018 at 09:13 AM ·
uiinputfield
how to validate input field if its null it gets color red in outline.
Hi everyone. im tring to validate a inputfield if it null onsubmit the inpu field outline will turns red
if (playerInputName.text == "")
{
//what should i put in this line to get the input field outline turns red?
}
else
{
SceneManager.LoadScene("ScoreBoardGradetwo");
}
Comment
Answer by Lilius · Feb 24, 2018 at 09:46 AM
The outline seems to be in the image itself, so yo must change the image. Also you're checking if text is empty so your code does not work if it is null. Use IsNullOrEMpty instead.
if (string.IsNullOrEmpty(playerInputName.text))
{
playerInputName.image = yourNewImageHere;
}