|
25 | 25 |
|
26 | 26 | value = jQuery.trim(value); |
27 | 27 |
|
28 | | - if ((options.unique && $(this).tagExist(value)) || !_validateTag(value, options)) { |
| 28 | + if ((options.unique && $(this).tagExist(value)) || !_validateTag(value, options, tagslist)) { |
29 | 29 | $('#' + id + '_tag').addClass('error'); |
30 | 30 | return false; |
31 | 31 | } |
|
109 | 109 | placeholder: 'Add a tag', |
110 | 110 | minChars: 0, |
111 | 111 | maxChars: null, |
| 112 | + limit: null, |
112 | 113 | width: 'auto', |
113 | 114 | height: 'auto', |
114 | 115 | autocomplete: {selectFirst: false}, |
|
194 | 195 | focus: true, |
195 | 196 | unique: settings.unique, |
196 | 197 | minChars: settings.minChars, |
197 | | - maxChars: settings.maxChars |
| 198 | + maxChars: settings.maxChars, |
| 199 | + limit: settings.limit |
198 | 200 | }); |
199 | 201 | } |
200 | 202 | }); |
|
205 | 207 | focus: true, |
206 | 208 | unique: settings.unique, |
207 | 209 | minChars: settings.minChars, |
208 | | - maxChars: settings.maxChars |
| 210 | + maxChars: settings.maxChars, |
| 211 | + limit: settings.limit |
209 | 212 | }); |
210 | 213 |
|
211 | 214 | return false; |
|
217 | 220 | focus: true, |
218 | 221 | unique: settings.unique, |
219 | 222 | minChars: settings.minChars, |
220 | | - maxChars: settings.maxChars |
| 223 | + maxChars: settings.maxChars, |
| 224 | + limit: settings.limit |
221 | 225 | }); |
222 | 226 |
|
223 | 227 | return false; |
|
233 | 237 | focus: true, |
234 | 238 | unique: settings.unique, |
235 | 239 | minChars: settings.minChars, |
236 | | - maxChars: settings.maxChars |
| 240 | + maxChars: settings.maxChars, |
| 241 | + limit: settings.limit |
237 | 242 | }); |
238 | 243 |
|
239 | 244 | return false; |
|
280 | 285 | focus: false, |
281 | 286 | callback: false, |
282 | 287 | minChars: 0, |
283 | | - maxChars: null |
| 288 | + maxChars: null, |
| 289 | + limit: null |
284 | 290 | }); |
285 | 291 | } |
286 | 292 |
|
|
290 | 296 | } |
291 | 297 | }; |
292 | 298 |
|
293 | | - var _validateTag = function(value, options) { |
| 299 | + var _validateTag = function(value, options, tagslist) { |
294 | 300 | var result = true; |
295 | 301 |
|
296 | 302 | if (value === '') result = false; |
297 | 303 | if (value.length < options.minChars) result = false; |
298 | 304 | if (options.maxChars !== null && value.length > options.maxChars) result = false; |
| 305 | + if (options.limit !== null && tagslist.length >= options.limit) result = false; |
299 | 306 |
|
300 | 307 | return result; |
301 | 308 | }; |
|
0 commit comments