Accessing a form component's Name or Type

I’m attempting to run client-side form field validations. I’ve added all of the components into an List so that I can iterate through them and pull their current values and do my validation checks.

The problem I’m running into is that to access the current value of a textbox (self.firstname_textbox.text) throws an error when using some other component types like a Drop Down that doesn’t have a .text property.

Question: Is there a way I can access a component’s name or type (eg label, dropdown, checkbox, etc) so I can use a conditional to access the component’s current value using the appropriate property (eg .text .selected_value)?

Thanks.

2 Likes

I have done this to check component types:

for comp in my_list:
  if type(comp) is TextBox:
      
    # your conditional processing here, example:
    # text=comp.text

Would something like this work for you?

4 Likes

Thank you so much. That works perfectly.

Thank you. This helped me too when I came searching.

1 Like