开发者

Text limit inside <span> XHTML?

I would like to limit the text inside a开发者_如何学JAVA tag so when I add a new article in my ASP admin panel, it only has 350 characters max.

How do I go about doing this?


You can't do this with a tag, except if it's an input tag.

<input type="text" id="mytext" name="blah" maxlength="10" />

Of course you can make this limit using javascript or server side programing.

For instance, here is how to do it for a textarea : http://www.mediacollege.com/internet/javascript/form/limit-characters.html


This depends how you ask the user for input. The <input> tag can have a maxlength attribute which should be respected by the browsers.

You can also use some client-side JavaScript to apply and notify the user of the limit, but you still need to check it on the server before committing it to your database (as I assume you want to do), because for any reason you could still getmore characters in the request to the server (hand-crafted query etc.).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜