Last active
May 27, 2016 14:38
-
-
Save deniskyashif/9276a7d9b88a28ffd92ab2e2dcff98ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validator = $('#form').kendoValidator({ | |
messages: { | |
text: 'Field must contain at most 20 symbols.', | |
grid: 'The grid must contain at least two rows.' | |
}, | |
rules: { | |
text: function(item) { | |
if (item.is('[name=text]')) { | |
return item.val().length < 20; | |
} | |
return true; | |
}, | |
grid: function(item) { | |
if (item.is('[data-role=grid]')) { | |
var grid = item.getKendoGrid(); | |
return grid.dataItems().length > 1; | |
} | |
return true; | |
} | |
} | |
}).data('kendoValidator'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="form"> | |
<textarea name="text" rows="1" cols="40">Our world is a magical smoke screen</textarea> | |
<div id="grid"></div> | |
<button id="validate">Validate</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isValid = validator.validate() && validator.validateInput('#grid'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment