Validation of data entry fields and focus

Hi,
Follow a login screen as “example” that I would like to know how to validate text input email and password

When I trie to test if email is empty and set st.stop it doesnt raise and go ahead, this is one problem and another is that I need to set focus when validation not sucess.
I try to use callback without success !

I could suggest Streamlit to create somenthing to set focus element, like : st.focus(email)

This is what happens when I try to click login button

When I used st.stop I thought the program flow would stop but it didn’t

image

It would be interesting for Streamlit to have a st.stop function like in the image

Could anyone tell me the best way to handle this?
Thanks

I also have a similar question. I need to validate a number input.

I tried the following code. Though I have given a key value for the widget. still It have the streamlit.errors.DuplicateWidgetID: error.
Really appreciate if anyone can help

import streamlit as st
while True:
user_input = st.text_input("Enter the number : ", key=1)
try:
user_input = int(user_input)
break
except ValueError:
print(‘Invalid : Try enter a number’)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.