Saturday, 18 November 2017

Calculate textarea characters using jquery

/////////////////////// html

<asp:TextBox ID="txt_Remarks" runat="server" CssClass="form-control" TextMode="MultiLine"

 MaxLength="150" Height="50px" onkeyup="return txt_area_Charc(this, 'txtCCountChar', 150)"></asp:TextBox>


//plugin-


     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>


///////////// js
function txt_area_Charc(val, txtcid, mval) {
    var len = val.value.length;
    if (len >= mval) {
        val.value = val.value.substring(0, mval);
        if (len == mval && txtcid != "") {
            $('#' + txtcid).text((mval - (len)) + " Character Left");
        }
        return false;
    } else {
        if (txtcid != "") {
            $('#' + txtcid).text((mval - (len)) + " Character Left");
        }
    }

}

// result


No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...