Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
User : User ( 0)
PHP Version : 7.4.6
Disable Function : NONE
Directory :  C:/Program Files (x86)/Microsoft Office/OFFICE11/SAMPLES/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : C:/Program Files (x86)/Microsoft Office/OFFICE11/SAMPLES/MaxLength.htc
<PUBLIC:COMPONENT id="bhvmaxLength" urn="sUrnmaxLength">
<PUBLIC:PROPERTY name="maxLength" />
<PUBLIC:ATTACH EVENT="onload" FOR=window ONEVENT="InitMaxLength()" />
<PUBLIC:ATTACH EVENT="onkeypress" FOR=element ONEVENT="KeyPress()" />
<PUBLIC:ATTACH EVENT="onpaste" FOR=element ONEVENT="Paste()" />

<SCRIPT language="VBScript">
	Dim NOTSET
	NOTSET = -1

	'Initialize maxLength (ie. check to see if maxLenght property is set)
	Sub InitMaxLength
		If IsNull(maxLength) Then
			'maxLength is not defined, therefore there is no max length.
			'NOTSET (-1) will be our flag to denote no max length.
			maxLength = NOTSET
		End If
	End Sub

	Sub KeyPress
		Dim objTR

		Set objTR = element.document.selection.createRange()
		If Len(objTR.text) >= 1 Then						'Allows a user to type over selected text
											'even if maxLength has been reached.
			window.event.returnvalue = TRUE
		ElseIf (Not (maxLength = NOTSET)) AND (Not IsNuLL(maxLength)) Then	'Do not impose maxLength if property not set.
			If Len(value) >= CInt(maxLength) Then
				window.event.returnvalue = FALSE			'Do not allow user to exceed maxLength characters
			End If
		End If
	End Sub

	Sub Paste
		Dim objTR
		Dim intInsertLength
		Dim strPasteData

		'Redefine the paste behavior to only paste as much as is allowed without
		'exceeding the maxLength
		If (Not (maxLength = NOTSET)) AND (Not IsNull(maxLength)) Then
			window.event.returnvalue = FALSE				'"Turns Off" the default event action
			Set objTR = element.document.selection.CreateRange()
			intInsertLength = CInt(maxLength) - Len(value) + Len(objTR.text)
			if intInsertLength < 0 then intInsertLength = 0		'If the element contains the maximum number of characters, then paste nothing.
			strPasteData = Left(window.clipboardData.getData("Text"), intInsertLength)
			objTR.text = strPasteData
		End If
	End Sub
</SCRIPT>
</PUBLIC:COMPONENT>