You must Sign In to post a response.
  • Category: HTML

    Text Area maximum length

    How to maxlength in Html Textarea control. Below code is not working. Please assist.

    <textarea maxlength="50">
    Enter text here...
    </textarea>
  • #736113
    Hi Bujji,

    Try this one.. It may help u
    <html>
    <body>

    <H1> This is for creating the maximum lenght of textarea in HTML </H1>
    <textarea rows="4" cols="50" maxlength="50">
    Enter Your text Here </textarea>


    </body>
    </html>

  • #736124
    'maxlength' in textarea is introduced newly in HTML5 it is not exist in HTML 4 that is regular html it is not exist. you need to take help of javascript to check the length of textarea
    see below code snippet

    <script language="Javascript">
    function checkLength()
    {
    if(document.getElementById("txtArea").value.length > 50)
    {
    alert('Please insert only 50 characters');
    return false;
    }
    }
    </script>
    //call above function on Textarea onkeypress
    <Textarea cols="3" rows="3" onkeypress="return checkLength();">

    hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #736129
    hey, check this example it will help you,

    http://www.w3schools.com/tags/att_input_maxlength.asp

    Thanks,
    ketan

  • #736131
    What is the problem you are having.



    <textarea maxlength='250' name=''>\
    ur value here

    </textarea>

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #736171
    Hi,

    Your code works fine if you are using internet explorer 10 or above.

    maxlength attribute of the textarea is introduced recently so it is not advisable to use this feature at this time as many people still uses IE 8 or 9.


    Regards,
    Asheej T K

  • #736363
    <html>
    <body>

    <form action="demo_form.asp">
    Enter Text: <input type="text" name="mytext" maxlength="50"><br>
    <input type="submit" value="Submit">
    </form>

    </body>
    </html>

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #744517
    Hi,

    Set Text Area maximum length--


    <!DOCTYPE html>
    <html>
    <body>

    <textarea rows="4" cols="50" maxlength="10">
    Enter text here...</textarea>

    </body>
    </html>


    Regards

    Regards,
    Dipti Choudhari


  • Sign In to post your comments