Using a password field on a form | Community
Skip to main content
Ronen-Was-SRpro
New Participant
July 9, 2018
Solved

Using a password field on a form

  • July 9, 2018
  • 1 reply
  • 5344 views

Hi all,

A customer wants to have a password field on a form, do you have any suggestions about how to do that?

I'm asking since this is not a native type of form field (the characters should be hidden and sent to the system). I know it's possible by JS, but any specific ideas on how to do that properly?

Thanks,

Ronen

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

MktoForms2.whenReady(function(form) {

   var formEl = form.getFormElem()[0],

       passwordEl = formEl.querySelector("[name='YourPasswordFieldName']");

  

   passwordEl.setAttribute("type","password");

});

Bear in mind a type=password field doesn't do anything but hide characters from the end user (and people snooping over their shoulder). Has nothing to do with database storage.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
July 9, 2018

MktoForms2.whenReady(function(form) {

   var formEl = form.getFormElem()[0],

       passwordEl = formEl.querySelector("[name='YourPasswordFieldName']");

  

   passwordEl.setAttribute("type","password");

});

Bear in mind a type=password field doesn't do anything but hide characters from the end user (and people snooping over their shoulder). Has nothing to do with database storage.

Ronen-Was-SRpro
New Participant
July 9, 2018

Thanks SW,

So JS, as I thought,

I wonder how this wasn't dealt before... I will open an idea about this...

Ronen Wasserman
Grégoire_Miche2
New Participant
July 9, 2018

The reason why it has not been dealt with before is because Marketo is not a safe place to store passwords (field values can be openly read by users and extracted from the database with a simple token in an email or a landing page) and Marketo offers no authentication mechanism (comparing the entered password to the stored value in order to grant access to something).

So the capturing a password in a Marketo form is very limited.

-Greg