# NGUI UIInput - Reset value of password field

How do I reset the value of a NGUI UIInput control that marked Is Password. If I set .text to "" I still see a bunch of ********** rather than the .defaultText.

Basically if the user types the wrong password during login, I want to clear the field and have is display the default text again.

## Update

If I click into the field and back out, the default text shows, but until I do that I get the **********.

Code:

// Show the Create dialog
public void ShowCreate() {
panelWait.gameObject.SetActive(false);
panelLogin.gameObject.SetActive(false);
panelCreate.gameObject.SetActive(true);

username = loginUsername.text;
createUsername.text = username;
createPasswordA.text = "";
createPasswordB.text = "";
}


Image:

• Could you show us your actual code? Because what you describe should just work. Set the my_uiinput.text = ""; should clear it just fine. – Bart Feb 6 '13 at 13:46
• It might be that the widget doesn't have the focus. Could you try setting selected to true and see if that changes anything? i.e. createPasswordA.selected = true; – Bart Feb 7 '13 at 10:01
• @Bart - write that as an answer. Had to add all three to make it work right: createPasswordB.selected = true; createPasswordA.selected = true; createUsername.selected = true; – Justin808 Feb 7 '13 at 17:28

## 1 Answer

Normally setting the text member to "" should clear the UIInput. However, for this to take effect, the widget does need to have the focus (selected needs to be true). If your widget does not immediately clear, you can set its focus manually.

In your case that would be:

createPasswordA.selected = true;
createPasswordB.selected = true;
createUsername.selected = true;


That should do the trick.