Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:15:53+00:00 2026-06-16T19:15:53+00:00

I’m trying to use the ClientHandler.validateMatches() method to hide/display and enable/disable some elements of

  • 0

I’m trying to use the ClientHandler.validateMatches() method to hide/display and enable/disable some elements of a ui. I’m adding two ClientHandlers but only one actually seems to execute as expected. Code is as follows:

function doGet(e) {
  var app = UiApp.createApplication();
  var grid = createAdultInfoGrid(135, 8);

  app.add(grid);
  return app;
}

/* Element id for adult-specific information grid element */
var GRID_ADULTS_ID = 'G_AdultInfo';
/* Element id for driver status field */
var PARTICIPANT_DRIVER_ID = 'P_IsDriver';
/* Element id for seatbelt count field */
var PARTICIPANT_SEATBELT_COUNT_ID = 'P_BeltCount';
/* Element id for seatbelt count status message field */
var PARTICIPANT_SEATBELT_MSG_ID = 'P_BeltCountMsg';

/**
 * Creates a new grid for display of adult-specific information using the GRID_ADULTS_ID constant as its id
 * @param pLblWidth - the width to be used for labels
 * @param pCellPadding - the value to be used for cell padding in the resulting grid
 */
function createAdultInfoGrid(pLblWidth, pCellPadding) {
  Logger.log("Creating adult participant information grid . . .");
  var app = UiApp.getActiveApplication();
  var grid = app.createGrid(2, 3).setId(GRID_ADULTS_ID).setCellPadding(pCellPadding);

  Logger.log("Creating listbox - driver . . .");
  var lstBoxDriver = app.createListBox().setId(PARTICIPANT_DRIVER_ID).setName('DriverStatus');
  lstBoxDriver.setVisibleItemCount(1);
  lstBoxDriver.addItem('Yes');
  lstBoxDriver.addItem('No');  
  lstBoxDriver.setItemSelected(0, true);

  Logger.log("Creating textbox - seatbelts . . .");
  var txtBoxSeatBelts = app.createTextBox().setId(PARTICIPANT_SEATBELT_COUNT_ID).setValue('2');
  var labelBeltStatus = app.createLabel('Please enter a number between 1 and 15.').setId(PARTICIPANT_SEATBELT_MSG_ID).setWidth(pLblWidth * 2).setVisible(false);
  var driverYesHandler = app.createClientHandler()
      .validateMatches(lstBoxDriver, '([Yy][Ee][Ss]){1}')
      .forTargets(txtBoxSeatBelts)
      .setText('')
      .setEnabled(true)
      .setVisible(true)
      .setStyleAttribute("color", "black")
      .setStyleAttribute("background", "white")
      .forTargets(labelBeltStatus)
      .setVisible(false);

  var driverNoHandler = app.createClientHandler()
      .validateMatches(lstBoxDriver, '([Nn][Oo]){1}')
      .forTargets(txtBoxSeatBelts)
      .setText('0')
      .setEnabled(false)
      .setVisible(true)
      .setStyleAttribute("color", "black")
      .setStyleAttribute("background", "white")
      .forTargets(labelBeltStatus)
      .setVisible(false);

  lstBoxDriver.addChangeHandler(driverYesHandler);
  lstBoxDriver.addChangeHandler(driverNoHandler);

  Logger.log("Adding listbox - driver . . .");
  grid.setWidget(0, 0, app.createLabel('I am willing to drive:').setWidth(pLblWidth));
  grid.setWidget(0, 1, lstBoxDriver);

  Logger.log("Adding textbox - seatbelts . . .");
  grid.setWidget(1, 0, app.createLabel('Seatbelts:').setWidth(pLblWidth));
  grid.setWidget(1, 1, txtBoxSeatBelts);
  grid.setWidget(1, 2, labelBeltStatus);

  app.close();
  return grid;
}

When accessed in a browser, I can change the listbox to ‘No’ from ‘Yes’ and the ClientHandler works (text is set to 0, field is disabled, etc). But when the listbox is changed from ‘No’ to ‘Yes’, the expected actions are not performed – the form remains in the same state. I’ve tried using ‘Yes’ and ‘No’ as the regex pattern with the ‘i’ flag specified – also tried using validateNotMatch() method, but to no avail. The event doesn’t seem to be caught after the first change is made from default values. Any suggestions would be appreciated.

thanks in advance,
dgg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:15:54+00:00Added an answer on June 16, 2026 at 7:15 pm

    See the open bug Issue 1226.
    There is a bug with ClientHandlers and ListBoxes such that regardless of the validation the handler will always fire. Therefore both of your handlers are firing, and as your ‘No’ handler was added last, that is the one which runs last. You can prove this by reversing the order in which you add the ChangeHandlers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am confused How to use looping for Json response Array in another Array.
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.