Class PasswordTextBox


Deprecated. The UI service was deprecated on December 11, 2014. To create user interfaces, use the HTML service instead.

A text box that visually masks its input to prevent eavesdropping.

Here is an example of how to use this widget:


 function doGet() {
   var app = UiApp.createApplication();
   var text = app.createPasswordTextBox().setName("text");
   var handler = app.createServerHandler("test").addCallbackElement(text);
   app.add(app.createButton("Test", handler));
   app.add(app.createLabel("0 characters").setId("label"));
   return app;

 function test(eventInfo) {
   var app = UiApp.createApplication();
   // Because the text box was named "text" and added as a callback element to the
   // button's click event, we have its value available in eventInfo.parameter.text.
   var pass = eventInfo.parameter.text;
   var isStrong =
       pass.length >= 10 && /[A-Z]/.test(pass) && /[a-z]/.test(pass) && /[0-9]/.test(pass);
   var label = app.getElementById("label");
   if (isStrong) {
     label.setText("Strong! Well, not really, but this is just an example.")
         .setStyleAttribute("color", "green");
   } else {
     label.setText("Weak! Use at least 10 characters, with uppercase, lowercase, and digits")
         .setStyleAttribute("color", "red");
   return app;

Internally, UiApp widgets are built on top of the Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation directly. You can find the PasswordTextBox documentation here.

Deprecated methods

Send feedback about...

Apps Script
Apps Script