Semantic-ui: Adding rules to form validation does not work

Created on 4 Apr 2017  路  1Comment  路  Source: Semantic-Org/Semantic-UI

Having following Javascript code:

$.fn.form.settings.rules.recaptcha = function(value, t)
{
    if (grecaptcha.getResponse() == ""){
        return false;
    } else {
        return true;
    }
};


$('.ui.form')
  .form({
    fields: {
        "business[name]"            : 'empty',
        "business[description]"     : 'empty',
        "hidden" : {
          identifier: 'hidden',
          rules: [
          {
              type: 'recaptcha',
              prompt: 'Please prove that you are not a robot.'
          }]
      }
    }
  })
;

I am hitting a TypeError: e.type.match is not a function error:

form.min.js:10 Form: There is no rule matching the one you specified hidden
error @ form.min.js:10
rule @ form.min.js:10
(anonymous) @ form.min.js:10
each @ jquery-3.2.1.min.js:2
field @ form.min.js:10
(anonymous) @ form.min.js:10
each @ jquery-3.2.1.min.js:2
isValid @ form.min.js:10
form @ form.min.js:10
dispatch @ jquery-3.2.1.min.js:3
q.handle @ jquery-3.2.1.min.js:3
trigger @ jquery-3.2.1.min.js:4
(anonymous) @ jquery-3.2.1.min.js:4
each @ jquery-3.2.1.min.js:2
each @ jquery-3.2.1.min.js:2
trigger @ jquery-3.2.1.min.js:4
r.fn.(anonymous function) @ jquery-3.2.1.min.js:4
submit @ form.min.js:10
dispatch @ jquery-3.2.1.min.js:3
q.handle @ jquery-3.2.1.min.js:3
form.min.js:10 Uncaught TypeError: e.type.match is not a function
    at Object.bracketedRule (form.min.js:10)
    at Object.ancillaryValue (form.min.js:10)
    at Object.rule (form.min.js:10)
    at Object.<anonymous> (form.min.js:10)
    at Function.each (jquery-3.2.1.min.js:2)
    at Object.field (form.min.js:10)
    at Object.<anonymous> (form.min.js:10)
    at Function.each (jquery-3.2.1.min.js:2)
    at Object.isValid (form.min.js:10)
    at HTMLFormElement.form (form.min.js:10)

I am using:

"semantic-ui": "^2.2.10"

Usage Question

Most helpful comment

Hi @bluszcz, you can鈥檛 combine shorthand syntax with full syntax; it should either be short, or full鈥攏ot both.

>All comments

Hi @bluszcz, you can鈥檛 combine shorthand syntax with full syntax; it should either be short, or full鈥攏ot both.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arj-196 picture arj-196  路  3Comments

zhaoyao91 picture zhaoyao91  路  3Comments

ghost picture ghost  路  3Comments

kntmrkm picture kntmrkm  路  3Comments

deneuxa picture deneuxa  路  3Comments