2.0.3 • Published 9 years ago

knockout-parsley v2.0.3

Weekly downloads
2
License
-
Repository
github
Last release
9 years ago

#Knockout Parsley Parsley validation for Knockout JS.

License: MIT

##Usage

// Init the plugin
ko.parsley.init('#main-form');

var viewModel = {
  // Add a simple rule to the observable
  value1:  ko.observable().extend({ required: true }),

  // Add rule with custom message
  value2: ko.observable().extend({
    type: { 
      params: "email",
      message: "This is not a valid email address!"
    }
  }),

  // Add rule with condition
  // The condition must be a function returning  a boolean value. 
  // If the returned value is false, the validation will not apply.
  value3: ko.observable().extend({
    required: {
      params: true,
      condition: function(_viewModel) {
        return _viewModel.value1() === 'Some Text';
      }
    }
  })  
};

// Apply Knockout bindings
ko.applyBindings(viewModel);

##Rules You can use the following Parsley rules:

  • required
  • minlength
  • maxlength
  • length
  • min
  • max
  • pattern
  • range
  • type

Learn more about the rules on the Parsley Documentation Site

2.0.3

9 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago