Set the default value for a password field on a custom form
I think you are choosing password type field. Like below  for password and confirm password fields.

'#type' =&gt; 'password', 


Password does not support '#default_value' property. So fields getting cleared.