MomasVII
MomasVII

Reputation: 5071

Create key value javascript values

I am trying to copy a simple example from here: https://via-profit.github.io/js-form-validator/ But I get Uncaught SyntaxError: Unexpected token ':'

`

var formHandle = document.querySelector('#myform'),
    options: { //ERROR REFERS TO THIS LINE

        // set a custom rule
        rules: {
            milk: function (value) {
                return (value.trim().toLowerCase() === 'milk');
            }
        },

        // set a incorrect message text
        messages: {
            en: {
                milk: {
                    incorrect: 'This is not a Milk ;-)'
                }
            }
        }
    };

// Got to validation
new Validator(formHandle, function (err, res) {
    return res;

}, options);`

Am i doing something super dumb here? I copy and pasted there example. What have I done wrong?

Upvotes: 2

Views: 50

Answers (2)

arve
arve

Reputation: 801

may be it is the back tick at the end of your last line -> }, options);`

Upvotes: 0

Vivek Patel
Vivek Patel

Reputation: 1057

I think documentation is wrong. It should be

var formHandle = document.querySelector('#myform');
var options = {

    // set a custom rule
    rules: {
...

Please try this. It will work.

Upvotes: 3

Related Questions