javascript代码限制文本框只有20个单词 [英] javascript code to restrict textbox only 20 words

查看:44
本文介绍了javascript代码限制文本框只有20个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 限制数字 字a  user 可以将输入一个文本框 一个asp。网络形式。我认为需要 的字数  用户  输入 然后 达到最大字数时停止。是否有人任何示例   这样做?

解决方案

无需使用Javascript,使用 MaxLength 属性文本框。

例如。

 <   asp:textbox     id   =  txt    runat   =  server    maxlength   =  20 >  <   / asp:textbox  >  





祝你好运。


I need to limted the number of words a user can enter into a textbox on an asp.net webform.  I suppose that the words need to be counted as the user is entering them and then stopped when they reach the maximum word count.  Does anybody have any examples of how to do this?

解决方案

No need to use Javascript, Use MaxLength property of textbox.
Eg.

<asp:textbox id="txt" runat="server" maxlength="20"></asp:textbox>



Good luck.


这篇关于javascript代码限制文本框只有20个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆