Skip to content

Instantly share code, notes, and snippets.

@scottswaaley
Created August 3, 2016 17:23
Show Gist options
  • Save scottswaaley/b88a9a5e7c2210aa7cec03bf731f99f9 to your computer and use it in GitHub Desktop.
Save scottswaaley/b88a9a5e7c2210aa7cec03bf731f99f9 to your computer and use it in GitHub Desktop.
function doGet() {
var app = UiApp.createApplication();
var tb = app.createTextBox().setName("tb1");
var lab1 = app.createLabel("This box wants only numbers. If you put in something other than a number, it will turn red.");
var badInput = app.createClientHandler().validateNotNumber(tb).forEventSource().setStyleAttribute("background", "red"); // turns red when a non-number is entered
var goodInput = app.createClientHandler().validateNumber(tb).forEventSource().setStyleAttribute("background", "white"); // turns white again when a number is entered
tb.addChangeHandler(badInput).addChangeHandler(goodInput);
app.add(lab1).add(tb);
return app;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment