×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jing Tai Piao
Added: Mar 5, 2013 6:50 AM
Views: 12
Tags: no tags
  1. $.validator.addMethod('rangelength', function (value, element) {
  2.         var maxlen = parseInt($(element).attr('data-val-length-max'));
  3.         if (maxlen > 0) {
  4.             var remaining = (maxlen - (parseInt($(element).val().replace(/(\r\n|\n|\r)/gm, '\r\n').length)));
  5.             if (remaining < 0) {
  6.                 return false;
  7.             }
  8.         }
  9.  
  10.         return true;
  11.     });