Create key value javascript values

Viewed 41

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?

2 Answers

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.

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

Related