473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Client side script concepts - Textbox string length

I have as an example this very simple page

<html>
<head>
</head>
<body>
<form id="myForm" runat="server">
<asp:textbox id="input" runat="server" />
<br>
<asp:label id="inputLength" runat="server" />
</form>
</body>
</html>

I want the label to reflect the length of the string being typed in
the textbox and update on every keystroke. Any ideas?
Nov 18 '05 #1
3 1646
<html><head><script language="javascript" for="input" event="onchange"

var strInput = this.value
window.document.all.inputLength = strInput.length

</script></head><body><form id="myForm" runat="server"><asp:textbox id="input" runat="server" /><br><asp:label id="inputLength" runat="server" /></form></body></html>
Nov 18 '05 #2
besides not working (onchange will not fire until focus leaves the field)
its pretty non w3c compliant code, try:

<html>
<head>
<script language="javascript">
function displayLength(e) {
document.getElementById('inputLength').innerHTML =
e.value.length;
}
</script>
</head>
<body>
<form id="myForm" runat="server">
<asp:textbox id="input" runat="server"
onkeyup="displayLength(this)" /><br>
<asp:label id="inputLength" runat="server" />
</form>
</body>
</html>

"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
<html><head><script language="javascript" for="input" event="onchange">
{
var strInput = this.value;
window.document.all.inputLength = strInput.length;
}
</script></head><body><form id="myForm" runat="server"><asp:textbox

id="input" runat="server" /><br><asp:label id="inputLength" runat="server"
/></form></body></html>
Nov 18 '05 #3
Sorry one mistake:
<script language="javascript" for="input" event="onchange">
{
var strInput = this.value;
window.document.all.inputLength.value = strInput.length;
}
</script>
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cathryn Lindner | last post by:
I have a web form that has a checkbox on it and a textbox associated with it. I want the textbox to be displayed when the checkbox is checked and I want this to happen on the client-side instead of...
0
by: JR | last post by:
Hello, Although I consider myself a proficient C++ programmer (and am getting better everyday at C# :-) I am new to and having a little trouble with some of the concepts behind ASP and ASP.NET....
1
by: Jim Hammond | last post by:
I can get data from a client-side assembly to the server in two manual steps, but I need to be able to do it in one step. Step 1: The user presses the manually coded "Step 1" button, which calls...
2
by: Robert Wagner | last post by:
I've created a page using VS.NET and page validator controls. The client side validation works fine on IE, but does not even activate under "alternate" browsers like Mozilla, Opera, etc. Why is...
4
by: Sue | last post by:
ASP.NET web application, data grid with several fields (Labels), table below the datagrid with several textboxes and dropdown lookup tables. When a user clicks on the "Select" button in datagrid,...
7
by: moondaddy | last post by:
I want to dynamically create a JavaScript file and cache it on the client for re-use. I know how to write javascript to a web page from the code behind, but I don't know how to actually create a...
9
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control,...
0
by: Pitcairnia | last post by:
I have as an example this very simple page <html> <head> </head> <body> <form id="myForm" runat="server"> <asp:textbox id="input" runat="server" /> <br> <asp:label id="inputLength"...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.