Jump to content

Disable autocomplete in an edit of a form UNIGUI


ana.rodrigues

Recommended Posts

Hi,

I am developing an unigui application, and i would like not show saved passwords or users from google chrome.

I tried some solutions i read on forumns but none worked, such as 

UniSession.AddJS('$("input").attr("autocomplete", "off");

or

function afterrender(sender, eOpts)
{
      var me=sender.inputEl;      
    me.set({
        readonly: "readonly"
    });
    
    sender.addListener(
        'focus',
        function(sender, e, eOpts) {
            me.el.dom.removeAttribute('readonly');
        }
    );
}

How can i disable, saved passwords from appear, everytime i use an edit?

Thanks in advance.

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

Perhaps this way (from another forum post)? 

 

On 3/17/2017 at 8:06 PM, Sherzod said:

Hi,

 

Ok, can you try to use this approach?!:

 

In your password edit box:

 

1. P1 -> ClientEvents -> ExtEvents -> function afterrender:


function afterrender(sender, eOpts)
{
    var me=sender.inputEl;      
    me.set({
        readonly: "readonly"
    });
}  

2. P1 -> ClientEvents -> ExtEvents -> function focus:


function focus(sender, e, eOpts)
{
    var me=sender.inputEl;    
    me.el.dom.removeAttribute('readonly');
}

Best regards.

  • Like 1
Link to comment
Share on other sites

19 hours ago, Pep said:

See this video (minute 33.10)  to remove autofill.

Hi, thanks but i saw this video and does not explain how to remove the autofill. The author says that explanation is in another video, but he doesn't say which video has the explanation. Also, the rar file is damaged, don´t know if it has the source code or not.

Link to comment
Share on other sites

Can you try to use this approach?

In UniServerModule.CustomCSS property 

.txtPassword {
   -webkit-text-security:disc;
}

for more information about this: https://stackoverflow.com/questions/13822548/degrading-webkit-text-security

In Login Form:

edtPassword.ClietnEvents.UniEvents -> beforeInit:
 

function beforeInit(sender, config)
{
   config.cls = 'txtPassword';
   
   config.readOnly = true;
   config.listeners={
      focus: function(edt) {
         edt.setReadOnly(false);
      }
   }   
}

UniLoginFormCreate Event

procedure TfrmLogin.UniLoginFormCreate(Sender: TObject);
begin
  // Set edtPassword as Input Type = "password"
  edtPassword.PasswordChar := '*';

  UserAgent.Caption := 'User Agent: ' + UniSession.UserAgent;
  if UniSession.UserAgent <> EmptyStr then
  begin
    if (Pos('chrome', LowerCase(UniSession.UserAgent))> 0) then
    begin
      // Browser is chrome and it's comptaible with css property -webkit-text-security:disc;
      // so you can set edtPassword Input Type = "text"
      edtPassword.PasswordChar := #0;
    end;
  end;
end;

See demo app:

DemoLogin.7z

  • Like 1
Link to comment
Share on other sites

On 9/26/2020 at 12:48 PM, Pep said:

Can you try to use this approach?

In UniServerModule.CustomCSS property 


.txtPassword {
   -webkit-text-security:disc;
}

for more information about this: https://stackoverflow.com/questions/13822548/degrading-webkit-text-security

In Login Form:

edtPassword.ClietnEvents.UniEvents -> beforeInit:
 


function beforeInit(sender, config)
{
   config.cls = 'txtPassword';
   
   config.readOnly = true;
   config.listeners={
      focus: function(edt) {
         edt.setReadOnly(false);
      }
   }   
}

UniLoginFormCreate Event


procedure TfrmLogin.UniLoginFormCreate(Sender: TObject);
begin
  // Set edtPassword as Input Type = "password"
  edtPassword.PasswordChar := '*';

  UserAgent.Caption := 'User Agent: ' + UniSession.UserAgent;
  if UniSession.UserAgent <> EmptyStr then
  begin
    if (Pos('chrome', LowerCase(UniSession.UserAgent))> 0) then
    begin
      // Browser is chrome and it's comptaible with css property -webkit-text-security:disc;
      // so you can set edtPassword Input Type = "text"
      edtPassword.PasswordChar := #0;
    end;
  end;
end;

See demo app:

DemoLogin.7z

Thank you. It worked!

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...