I am doing client side scripting in .NET. The scripting seems to work find until the third time. The thid time I enter something in a textbox the scripting fails to run. Anyone else have this problem or know why the script fails on the third try. This script add a dash after the second and sixth characters for formatting purposes.

<script language="vbscript" id="clientEventHandlersVBS">

Sub txtNIIN_onkeyup
If len(window.document.Form1.txtniin.value)= "2" then
window.Document.Form1.txtniin.value = window.Document.Form1.txtniin.value & "-"
End If

If len(window.Document.Form1.txtniin.value)= "6" then
window.Document.Form1.txtniin.value = window.Document.Form1.txtniin.value & "-"
End If

End Sub

</script>