VLWEB and Autofill

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jimwatterson
Posts: 28
Joined: Thu Jul 09, 2020 8:31 am

VLWEB and Autofill

Post by jimwatterson » Mon May 03, 2021 9:44 am

On some devices (depending upon settings) we are seeing input fields being automatically pre-filled by the browser, including user ids, email addresses and mobile phone numbers. The users have asked us to stop this but there is no setting in VLWEB that allows us to control this. LANSA support have no ideas. In a Webevent function we would use autocomplete='off". Apparently not all browsers respect this setting but as it appears to work in Chrome that has to be much better than nothing.

It seems to me that we can't be the first to encounter this issue. Anybody out there got any ideas?

BrendanB
Posts: 52
Joined: Tue Nov 24, 2015 10:29 am

Re: VLWEB and Autofill

Post by BrendanB » Mon May 03, 2021 12:26 pm

Jim,

This can be accomplished via a widget. (Widget should be a 'Control' widget, place it on the page and set to Visible(False).

Widget needs a method 'TurnOff' :

Code: Select all

  //
  // TurnOff - Turn Off Autocomplete on Inputs
  //
  PROTOTYPE.TurnOff = function()
  {

      let tagArr = document.getElementsByTagName("input");

      for (let i = 0; i < tagArr.length; i++) {
        tagArr[i].autocomplete = 'off';
      }

  }
  
in your view (you will need to add the widget to each view you wish to 'turn off autocomplete') have a boolean for '#prepared' and '#ACInitialised'

Code: Select all

Define_Com Class(#AutoCompleteOff) Name(#AutoCompleteOff)  Parent(#COM_OWNER)  Visible(False)

Define_Com Class(#PRIM_BOLN) Name(#ACInitialised)
Define_Com Class(#PRIM_BOLN) Name(#Prepared)
At the end of the Prepare event routine put:

Code: Select all

Evtroutine Handling(#COM_OWNER.Prepare)

* Normal Prepare logic for View.....

* put these 2 lines at the end

#Prepared := True
#COM_SELF.TurnOffAutoComplete

Endroutine
and add:

Code: Select all

Evtroutine Handling(#AutoCompleteOff.Initialize)

#ACInitialised := True

#COM_SELF.TurnOffAutoComplete

Endroutine

Mthroutine Name(TurnOffAutoComplete)

If (#ACInitialised *And #Prepared)

#AutoCompleteOff.TurnOff

Endif

Endroutine
That should set it off on a per-view basis. (remember, the HTML is built each time you show a view, meaning this code needs to run each time you show it).

This can be extended for other input types (although i am unsure what the exact input types we use are).

Brendan.

Post Reply