jeudi 21 juillet 2016

Knockout Validation onlyif object no function and pattern validation

I want to the priceMax was required, when title is empty.

I have code

self.searchParameters = {
    title: ko.observable().extend({
      refreshCountOffers: 500
    }),
    priceMax: ko.observable().extend({
      required: {
        onlyIf: function() {
          return  title==null;
        }
      },
      refreshCountOffers: 500
    })
  };

,but I get error 'title is not defined'.

How to disable option, which show error for pattern validation, when user input first letter?

postCode: ko.observable().extend({
  required: true,
  pattern: {
    message: 'Post code is not valid',
    params: '[0-9]{2}-[0-9]{5}'
  },
  refreshCountOffers: 500
})

my jsfiddle

Aucun commentaire:

Enregistrer un commentaire