Semantic-Org/Semantic-UI · error

You must specify a string identifier for each field

Error message

You must specify a string identifier for each field

What it means

Semantic UI Form internal error thrown from has.field() (form.js:636-637) when a field identifier passed to validation is not a string. The form relies on identifiers to look up fields by #id, [name=...], or [data-validate=...]; a non-string identifier short-circuits with this console error.

Source

Thrown at src/definitions/behaviors/form.js:1305

    input      : 'input',
    message    : '.error.message',
    prompt     : '.prompt.label',
    radio      : 'input[type="radio"]',
    reset      : '.reset:not([type="reset"])',
    submit     : '.submit:not([type="submit"])',
    uiCheckbox : '.ui.checkbox',
    uiDropdown : '.ui.dropdown'
  },

  className : {
    error   : 'error',
    label   : 'ui prompt label',
    pressed : 'down',
    success : 'success'
  },

  error: {
    identifier : 'You must specify a string identifier for each field',
    method     : 'The method you called is not defined.',
    noRule     : 'There is no rule matching the one you specified',
    oldSyntax  : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.'
  },

  templates: {

    // template that produces error message
    error: function(errors) {
      var
        html = '<ul class="list">'
      ;
      $.each(errors, function(index, value) {
        html += '<li>' + value + '</li>';
      });
      html += '</ul>';
      return $(html);
    },

View on GitHub (pinned to 597843ab84)

Solutions

  1. Ensure every field identifier in the fields object is a string (coerce with String(id) when generating from data).
  2. Confirm the value passed to form methods like 'is valid' / 'add field' / 'remove field' is a string name, not a jQuery or DOM object.
  3. Inspect the second console argument emitted alongside the message to find which identifier is non-string.

Example fix

// before
$('.ui.form').form('is valid', $('#email')[0]); // DOM node, not identifier
// after
$('.ui.form').form('is valid', 'email');
Defensive patterns

Strategy: type-guard

Validate before calling

function buildFields(raw) {
  var out = {};
  Object.keys(raw).forEach(function(k){
    var id = String(k);
    if (typeof raw[k] === 'string' || typeof raw[k] === 'object') out[id] = raw[k];
  });
  return out;
}

Type guard

function isStringIdentifier(id) { return typeof id === 'string' && id.length > 0; }

Prevention

When it happens

Trigger: Calling $('.ui.form').form('form', {fields: {...}}) or invoking validation where a field identifier resolves to a number, undefined, null, or object (e.g. building the fields object from a JSON map whose keys became numeric, or passing a DOM node instead of a string).

Common situations: Programmatically generating the fields config from server data; using a non-string key when constructing identifiers; calling form('is valid', someElement) with a jQuery object instead of the field name.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/7761864241c0eac8. Report an issue: GitHub.