How to enforce user to write text_input in specific rules

I have a streamlit form with username and password text_input fields.

  1. I want the user as he fills the username text_input field that any capital char written to be converted to low caps. I am looking to have this in the value the user is writing and not the value returned from text_input.
  2. Also I want the password text_input field to comply with specific complexity as the user is typing it (e.g. 9 chars, 1 capital, 1 special character, alpha-numeric).

This is like a simple registration form for username / password but I am clueless of how to do this for the value field as the user is interacting with the widget.