PHP Classes

File: vendors/gentelella/vendors/parsleyjs/src/extra/validator/words.js

Recommend this page to a friend!
  Classes of Jorge Castro   Gentelella BladeOne   vendors/gentelella/vendors/parsleyjs/src/extra/validator/words.js   Download  
File: vendors/gentelella/vendors/parsleyjs/src/extra/validator/words.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Gentelella BladeOne
Render templates using Bootstrap for presentation
Author: By
Last change:
Date: 3 years ago
Size: 857 bytes
 

Contents

Class file image Download
(function () { // minwords, maxwords, words extra validators var countWords = function (string) { return string .replace( /(^\s*)|(\s*$)/gi, "" ) .replace( /\s+/gi, " " ) .split(' ').length; }; window.Parsley.addValidator( 'minwords', function (value, nbWords) { return countWords(value) >= nbWords; }, 32) .addMessage('en', 'minwords', 'This value needs more words'); window.Parsley.addValidator( 'maxwords', function (value, nbWords) { return countWords(value) <= nbWords; }, 32) .addMessage('en', 'maxwords', 'This value needs fewer words'); window.Parsley.addValidator( 'words', function (value, arrayRange) { var length = countWords(value); return length >= arrayRange[0] && length <= arrayRange[1]; }, 32) .addMessage('en', 'words', 'This value has the incorrect number of words'); })();