读书人

js篇幅限制 提示

发布时间: 2012-07-01 13:15:00 作者: rapoo

js字数限制 提示
转自:http://www.veryhuo.com/a/view/18234.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=GBK" /><title>artTxtCount demo by liehuo.net</title><script type="text/javascript" src="http://www.veryhuo.com/uploads/common/js/jquery-1.4.2.min.js"></script><script type="text/javascript">/* tangbin - http://www.veryhuo.com - MIT Licensed */(function($){// tipWrap: 提示消息的容器// maxNumber: 最大输入字符$.fn.artTxtCount = function(tipWrap, maxNumber){var countClass = 'js_txtCount',// 定义内部容器的CSS类名fullClass = 'js_txtFull',// 定义超出字符的CSS类名disabledClass = 'disabled';// 定义不可用提交按钮CSS类名// 统计字数var count = function(){var btn = $(this).closest('form').find(':submit'),val = $(this).val().length,// 是否禁用提交按钮disabled = {on: function(){btn.removeAttr('disabled').removeClass(disabledClass);},off: function(){btn.attr('disabled', 'disabled').addClass(disabledClass);}};if (val == 0) disabled.off();if(val <= maxNumber){if (val > 0) disabled.on();tipWrap.html('<span target="_blank" title="planeArt">www.veryhuo.com</a></p><form action="" method="get"><div><textarea name="" cols="50" rows="3"></textarea></div><div><button type="submit">提交</button><span action="" method="get"><div><textarea name="" cols="50" rows="3"></textarea></div><div><button type="submit">提交</button><span method="get"><input id="test" name="" type="text" /><span id="test_tips" class="tips"></span><br /><button type="submit">提交</button></form></div></body></html><br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>

读书人网 >JavaScript

热点推荐