manared
Well-known member
- Joined
- Jun 1, 2006
- Messages
- 84
- Programming Experience
- 1-3
I am creating a website with vb.net 2005 and am using the new Master and Content pages. I once again have a textbox that I need to limit the characters in the box. I have the javascript code that I need to use for this task, but I do not know how to use it with the content page that has the text box. Here is the javascript function that I used on a different program:
Does anyone know how I call this function and where I put it, either in the master page or content page? I also do not know exactly how to call it in my content page either. Any help is appreciated, thanks!
HTML:
<script language="javascript">
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.innerText = maxlimit - field.value.length + " characters remaining";
}
function doPaste(control) {
maxLength = control.attributes["maxLength"].value;
value = control.value;
if(maxLength){
event.returnValue = false;
maxLength = parseInt(maxLength);
var oTR = control.document.selection.createRange();
var iInsertLength = maxLength - value.length + oTR.text.length;
var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
oTR.text = sData;
}
}
</script>
Last edited by a moderator: