Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Count the maximum length of textbox using Javascript
WhatsApp
Purushottam Rathore
4y
20.1
k
0
0
25
Blog
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"MexLength.aspx.cs"
Inherits=
"MexLength"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title>Maximum length counter</title>
<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);
else
countfield.value = maxlimit - field.value.length;
}
</script>
</head>
<body>
<form id=
"Form1"
name=
"myform"
runat=
"server"
>
<asp:TextBox ID=
"TextBoxMessage"
runat=
"server"
TextMode=
"MultiLine"
Height=
"60px"
onkeydown=
"textCounter(TextBoxMessage,LengthCount,25)"
onkeyup=
"textCounter(TextBoxMessage,LengthCount,25)"
></asp:TextBox>
<input readonly type=
"text"
name=
"LengthCount"
size=
"3"
maxlength=
"3"
value=
"25"
>
</form>
</body>
</html>
Count the maximum length of textbox using Javascript
Up Next
Allow Only Numeric Values and allow Only one DOT in TEXTBOX using JavaScript
Ebook Download
View all
JavaScript Interview Q & A
Read by 878 people
Download Now!
Learn
View all
Membership not found