Make input fields required* using st.form

When using streamlit form with many input fields or selectbox, how can I make a field as required ?

Hi @Neo,

Thanks for posting! You could add add an if statement to your code that executes if the submit button has been clicked and checks whether an input widget has been completed. If it hasn’t been completed, you can display a message telling the user to complete it. You should also set clear_on_submit to false so that the form doesn’t reset after being submitted, to account for the case in which the user needs to go back and fill in the required fields.