Limit Number of Characters in a TextArea using jQuery

jQuery MaxLength for INPUT and TEXTAREA: | Limit Number of Characters in a TextArea using jQuery:



In this post we see an Example in which we take a text box control and count number of entered character at run time. Some time we need this type of code when we working on web application. As like use restriction on comment section or Address section or some time when we take feedback for user. Here we consider solution of this type of code by using Jquery.

Asp.net jquery related other post:


How to limit characters inside a text area in asp.net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="limitofchacterintextbox.aspx.cs" Inherits="limitofchacterintextbox" %>

<!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>
<title> </title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type='text/javascript'>
    $(function () {
        $('#textarea1').keyup(function () {
            var desc = $('#textarea1').val();
            var len = desc.length;
            if (desc.length >= 150) {
                this.value = this.value.substring(0, 150);
            }
            $('#spam1').text(150 - len + ' Characters Left');
        });
    });
</script>
    <style type="text/css">
        #textarea1
        {
            width: 465px;
            height: 87px;
        }
    </style>
</head>
<body>
<div align="center">
<h1>limit characters inside a text area in asp.net |
<br />

Limit Number of Characters in a TextArea using jQuery:</h1>
    <br />
<textarea id="textarea1"></textarea><br/>
<span id="spam1"> 150 Characters left</span></div>
</body>
</html> 

Limit number of characters entered by Jquery:

Limit Number of Characters in a TextArea using jQuery

Restrict number of characters entered in textarea by jquery:


Some time we search this Question in google these type, We type on searchbox as like jQuery Limit Number of Characters in a TextArea or jquery textarea limit characters per line or jquery limit textarea length or jquery count characters in textarea or limit number of characters in textarea javascript or limit characters in textarea using javascript or jquery textarea max length and jquery textarea counter.

Asp.net Related Other Post:


Comments

Popular posts from this blog