Maxlength property

Hello,

How to set maxlength property when the edit type is string?

Thanks!

1 Reply

MK Mahalakshmi Karthikeyan Syncfusion Team February 4, 2016 12:41 PM UTC

Hi Jorge,

We can achieve this requirement with workaround by binding the keypress event to the unique id of editing element. Please refer the below code example for details.

<ej:TreeGrid ID="Treegrid" runat="server" EnableResize="true" //… >

//…

</ej:TreeGrid>


<script type="text/javascript">

              

        $(document).on("keypress", "#TreegridName", function (e) {

            var CharLength = $(e.target).val().length + 1;

            if (CharLength > 5) {             

                e.returnValue = false;

                if (e.preventDefault)

                    e.preventDefault();

            }

        });


    </script>

In the above we have restricted the “Name” field to enter above 5 characters. We have also prepared a sample based on this and you can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/Maxlength-143303496

Regards,

Mahalakshmi K.


Loader.
Up arrow icon