import streamlit as st
text = st.text_input(“Your text:”)
if len(text) == 2:
st.error(“You can’t use more than 10 characters”)
else:
st.error(“-----------------You can’t use more than 10 characters”) #st.success(text)
I am submitting my code; however, it does not verify the length of the text and fails to produce the correct result. I kindly request your assistance in providing the appropriate code that checks the length of the text input and clears the text input for new entries or barcodes.
regard
Dear boss
The code provided functions correctly when a user inputs data and presses enter; it executes a function, clears the textbox, and sets the focus for new user input. However, I intend to utilize a barcode scanner that produces a 16-character length output. My objective is to ensure that the function verifies whether the character length is 16, and if so, executes the function, sends the barcode to it, clears the textbox, and sets the focus for new barcode scanning.
Currently, the code clears and sets focus only after the enter key is pressed. I would like this process to occur automatically by checking the textbox character length or triggering the function immediately after barcode scanning. I appreciate your assistance in providing the correct code for this functionality.
import streamlit as st
if ‘something’ not in st.session_state:
st.session_state.something = ‘’
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.