Pages

Sunday, 2 February 2014

How to Set Maxlength for Multiline Textbox in Asp.net c#

How to Set Maxlength for Multiline Textbox in Asp.net c#

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>jQuery set maxlength for multiline textbox in asp.net</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"> </script>
    <script type="text/javascript"> $(function () { $('#txtdesc').keypress(function (e) { var txt = $(this).val(); if (txt.length > 50) { e.preventDefault(); } }); }); </script>
</head>
<body>
    <form id="form1" runat="server">
        <table>
            <tr>
                <td><b>Enter Text:</b> </td>
                <td>
                    <asp:textbox id="txtdesc" textmode="MultiLine" runat="server"></asp:textbox>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>



Live Demo:



jQuery set maxlength for multiline textbox in asp.net
Enter Text:


No comments:

Post a Comment