none
multiline text box field and Characters Restriction

    Question

  • Hi,

    I want to use a multiline text box field for a custom list but I want to restrict users to enter only 200 wards/1000 characters ..how can I achieve this?

    Thanks,
    San

    Thursday, June 11, 2009 5:06 PM

Answers

  • Hi, San

       

          Thanks for Suhaib solution, this is a simple and efficient way, and the key point is “Find multiline text Control”.

     

          It is a form fields customizing validation case in my mind, these two solutions also can achieve your goal:

     

    1.     ListItem event handler

    You can add your limitation logic when ItemAdding and ItemUpdating

     

    EventHandler sample link:

    http://karinebosch.wordpress.com/walkthroughs/sharepoint-event-handlers/

      

    And the main logic is:

    ------------------------------------

    if(item[“validationField”].ToString().Length>200)

    {

       //your logic

       e.Cancel=true.

       //your logic

    }

    ------------------------------------

    2.     Custom Field Control

    You can use customized field control for your validation, this is a little difficult for multiline text box  but it is moss-style.

    Custom fields sample:

     

    http://www.sharethispoint.com/archive/2006/08/07/23.aspx

     

     

          Would you please try both my and Suhaib’s solution and check if it would work?

                

          Best Regards,

          -Aaron

    Tuesday, June 16, 2009 9:49 AM

All replies

  • If its just one of the form then you can customize your in SD and add javascript to check for number of characters.  Or you can create your own custom field with validation logic within this field.


    Thanks,
    Suhaib Khan
    Thursday, June 11, 2009 5:54 PM
  • Hi, San

       

          Thanks for Suhaib solution, this is a simple and efficient way, and the key point is “Find multiline text Control”.

     

          It is a form fields customizing validation case in my mind, these two solutions also can achieve your goal:

     

    1.     ListItem event handler

    You can add your limitation logic when ItemAdding and ItemUpdating

     

    EventHandler sample link:

    http://karinebosch.wordpress.com/walkthroughs/sharepoint-event-handlers/

      

    And the main logic is:

    ------------------------------------

    if(item[“validationField”].ToString().Length>200)

    {

       //your logic

       e.Cancel=true.

       //your logic

    }

    ------------------------------------

    2.     Custom Field Control

    You can use customized field control for your validation, this is a little difficult for multiline text box  but it is moss-style.

    Custom fields sample:

     

    http://www.sharethispoint.com/archive/2006/08/07/23.aspx

     

     

          Would you please try both my and Suhaib’s solution and check if it would work?

                

          Best Regards,

          -Aaron

    Tuesday, June 16, 2009 9:49 AM
  • Thanks Aaron...

    I tried Suhaib solution of using a javascript, it does work for multi-line text field with plain text but does not work for multi-line text with Rich text and Enhanced Rich text. Actually we wanted a Enhanced text field. I followed the solution mentioned in this blog http://edinkapic.blogspot.com/2007/10/add-javascript-date-validation-into.html. Here getTagFromIdentifierAndTItle returns the a html field object for Rich and Enhanced rich text type but it returns null string object.value. Any idea why this does not work with Rich text and Enhanced Rich text types

    I tried list event, AddingListItem and UpdatingListItem, it works but displaying error message in a separate page looks very ugly ..so this cannot be a solution ..

    I think only option left for me is to create custom field ..that I never wanted to write ..hope this would work with Rich text and Enhanced Rich text type

    Thanks,
    San
    Tuesday, June 16, 2009 6:49 PM