dianping/cat · error · Error

invalid prompt type

Error message

invalid prompt type

What it means

bootbox.prompt only accepts input types for which it ships an HTML template (in this version: text, textarea, email, date, time, number, password, select, and later checkbox). The templates.inputs lookup happens before the input element is created, and an unknown inputType throws 'invalid prompt type'.

Source

Thrown at cat-home/src/main/webapp/assets/js/uncompressed/bootbox.js:444

          break;
      }

      return options.callback(value);
    };

    options.show = false;

    // prompt specific validation
    if (!options.title) {
      throw new Error("prompt requires a title");
    }

    if (!$.isFunction(options.callback)) {
      throw new Error("prompt requires a callback");
    }

    if (!templates.inputs[options.inputType]) {
      throw new Error("invalid prompt type");
    }

    // create the input based on the supplied type
    input = $(templates.inputs[options.inputType]);

    switch (options.inputType) {
      case "text":
      case "textarea":
      case "email":
      case "date":
      case "time":
      case "number":
      case "password":
        input.val(options.value);
        break;

      case "select":
        var groups = {};

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Restrict inputType to the types your bundled bootbox version supports — check templates.inputs in the shipped uncompressed/bootbox.js for the authoritative list.
  2. For unsupported types, use bootbox.dialog with custom HTML in the message, or fall back to a plain form.
  3. Normalize the value: inputType: (type || 'text').toLowerCase() — guards against typos and missing defaults.

Example fix

// before
bootbox.prompt({ title: 'Pick a color', inputType: 'color', callback: fn });

// after
bootbox.prompt({ title: 'Favorite color', inputType: 'text', value: '#ff0000', callback: fn });
Defensive patterns

Strategy: validation

Validate before calling

var SUPPORTED = ['text','textarea','email','date','time','number','password','select','checkbox'];
var type = (opts.inputType || 'text').toLowerCase();
if (SUPPORTED.indexOf(type) === -1) type = 'text';
opts.inputType = type;
bootbox.prompt(opts);

Type guard

function isSupportedInputType(t) {
  return ['text','textarea','email','date','time','number','password','select','checkbox'].indexOf(t) !== -1;
}

Prevention

When it happens

Trigger: bootbox.prompt({title: 'Pick', inputType: 'radio', callback: fn}); inputType: 'color', 'file', 'range', 'datetime-local', or leaving inputType undefined in a version where 'text' is not the default key present in templates.inputs.

Common situations: Expecting bootbox to mirror the full HTML5 input type list; version drift — upgrading bootbox changed the supported set (checkbox added in 4.3+, removed/renamed types across versions); typos in the type string ('Text', 'textarea ' with whitespace).

Related errors


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/5aa381ffb64e7cfd. Report an issue: GitHub.