Possible to conditionally show/hide a Text Field based on User Agent (browser type)?

  • jcarriere
    Asked on September 2, 2015 at 4:41 PM

    Looking to show a specific text field to users viewing the form on a certain platform only. Is it possible to detect the User Agent, then conditionally show or hide a specific text field?

    Example:

    Browser Type A (Chrome) -> Hide Text Field 1

    Browser Type B (Safari) ---> Show Text Field 1

    Thanks for any insight

  • Boris
    Replied on September 2, 2015 at 8:24 PM

    Yes, you can achieve this by using our Get User Agent widget. (manual: How to Add a Widget to your Form)

    Then, simply set up Conditional Logic to show or hide fields based on what the User Agent field contains:

    Possible to conditionally show/hide a Text Field based on User Agent (browser type)? Image 1 Screenshot 20

    Please let us know if you need further assistance, we will be happy to help.

  • jcarriere
    Replied on September 3, 2015 at 9:28 AM

    Great! Do you have a list (however specific or condensed it may be) of the general returns this field generates so I don't have to submit X amount of test orders across different devices to see how I need to specify my conditions?

    I'm mostly aiming at Internet Explorer, if possible to specify version that would be helpful.

  • David JotForm Support
    Replied on September 3, 2015 at 11:40 AM

    Here is a list of all the user agent strings for IE:

    http://www.useragentstring.com/pages/Internet%20Explorer/

    These are the same string that will be displayed from the widget, depending on which browser was used.

    If you have any further questions, let us know and we will be happy to help.

  • jcarriere
    Replied on September 4, 2015 at 9:41 AM

    I've made some attempts with this, and am having hit and miss results. Here is a screen shot of my Conditions for the Browser Information in regards to showing or hiding two cosmetic fields (an h2 header and a text field).

    Possible to conditionally show/hide a Text Field based on User Agent (browser type)? Image 1 Screenshot 20

    Interestingly, when testing in IE 8 and IE 7, the header is shown, but the text field underneath it does not and I cannot for the life of me figure out why that is.

    Also, I am receiving some warning dialogue boxes when loading the page in which my form is embedded (iframe embed):

    IE 8 Warning(s): http://i.imgur.com/fPDrErd.png  http://i.imgur.com/uvkRYvw.png  

    IE 7 Warning: http://i.imgur.com/2PDlVyN.png 

    Any insight or help is appreciated.

  • David JotForm Support
    Replied on September 4, 2015 at 11:37 AM

    Since IE7 and 8 will no longer be supported at the end of this year by Microsoft, any script errors and such that occur in either one are likely to not be addressed.  If you wouldn't mind providing us with the URL of your page, we will be happy to take a look, though I cannot guarantee that a fix will be implemented. 

  • jcarriere
    Replied on September 4, 2015 at 11:43 AM

    Disregarding the warning dialogues, do you have any insight as to what about my conditions are not functioning correctly?

  • Boris
    Replied on September 4, 2015 at 1:01 PM

    It seems that Internet Explorer, in its earlier incarnations, didn't support functions that we use for the Contains matching.

    Possible to conditionally show/hide a Text Field based on User Agent (browser type)? Image 1 Screenshot 40

    You should try using Starts with matching instead, as this works fine on Internet Explorer 8:

    Possible to conditionally show/hide a Text Field based on User Agent (browser type)? Image 2 Screenshot 51

    You can use the following two rules to match most versions of Internet Explorer 8 on the market:

    Mozilla/4.0 (compatible; MSIE 8.
    Mozilla/5.0 (compatible; MSIE 8.

    Possible to conditionally show/hide a Text Field based on User Agent (browser type)? Image 3 Screenshot 62

    I am not sure about Internet Explorer 7, as I don't have this version available for testing. I hope this helps.