A set of Backbone-Forms validators
bower install backbone-forms-validators
or
npm install backbone-forms-validators
Add packages to config file:
packages: [{
name: 'backbone-forms-validators',
location: 'bower_components/backbone-forms-validators',
main: 'bbf-validators'
}]
Use:
define['backbone-forms-validators', 'backbone-forms-validators/pl'], function() {
// Your code
}
<script type="text/javascript" src="bower_components/backbone-forms-validators/bbf-validators.js"></script>
<script type="text/javascript" src="bower_components/backbone-forms-validators/pl.js"></script>
<!-- Rest od code -->
require('backbone-forms-validators')
require('backbone-forms-validators/pl')
// Rest of code
var form = new Backbone.Form({
schema: {
emails: {
type: 'Text',
validators: [{
type: 'multiple',
base_type: 'email',
separator: ',',
message: 'Emails separated by colon'
}]
}
}
});
Validates phone number
var form = new Backbone.Form({
schema: {
phone: {
type: 'Text',
validators: ['phone']
}
}
});
Validates length of entered text
var form = new Backbone.Form({
schema: {
text: {
type: 'Text',
validators: [{
type: 'minlength',
minlength: 3
}]
}
}
});
Validates length of entered text
var form = new Backbone.Form({
schema: {
text: {
type: 'Text',
validators: [{
type: 'maxlength',
maxlength: 9
}]
}
}
});
Validates NIP (Polish tax identification number)
var form = new Backbone.Form({
schema: {
nip: {
type: 'Text',
validators: ['nip']
}
}
});
Validates Pesel (Polish identification number)
var form = new Backbone.Form({
schema: {
pesel: {
type: 'Text',
validators: ['pesel']
}
}
});
Validates REGON (Polish Taxpayer Identification Number)
var form = new Backbone.Form({
schema: {
regon: {
type: 'Text',
validators: ['regon']
}
}
});