I would like to limit the text inside a 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?
I would like to limit the text inside a 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?
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.).
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