Created
December 17, 2014 08:05
-
-
Save takuya/66b2b9dabc4ec1fe9a8d to your computer and use it in GitHub Desktop.
タイムズプラスログインのmaxlength.js
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
/// takuya | |
// いったい何がしたいの・・・ | |
$(function(){ | |
$('input[maxlength]').each(function(){ | |
var maxlength = $(this).attr('maxlength'); | |
var f = function(){ | |
if($(this).val().length <= maxlength){ | |
$(this).attr('maxlength', maxlength).unbind('keydown keypress keyup focus', f); | |
}else{ | |
$(this).removeAttr('maxlength'); | |
} | |
}; | |
$(this).bind('keydown keypress keyup focus', f); | |
if($(this).val().length <= maxlength){ | |
$(this).attr('maxlength', maxlength); | |
}else{ | |
$(this).removeAttr('maxlength'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment