Hi All,
SharePoint really provides many of the features out of the boxes. I would say 75% of feature it provides out of the box; however there are some scenarios where these features cannot help us.
Let me give you a classic example. Recently I got a simple requirement. When we create multiline text box in SharePoint, unfortunately there is no option to limit the number of characters in that. It is available in single line of text field but not in multiline text.
Ok, what is the solution? Yes, we can create custom field and ready to go. Yes I agree. But this will take time to create custom field and deploy on the server which may administrator in the company does not give access easily to upload anything.
Hummm…..So what to do? Answer is use jQuery. JQuery is here to save you.
All you have to do is add content editor web part on the page, and just bind keypressed event of textbox and count the number of characters. That is it. So simple. If it exceeds certain number of characters, you popup some message and then do not allow to enter more character in that.
Sounds great. Isn’t it? I know, yes of course.
At least this is far better than developing custom field type and then installs it in server through WSP.
Make sure that you add content editor web part in New Form as well as Edit Form both.
Let us say I have reason filed as multiline textbox in the list and I want to limit number of characters in that 100. We do not want to allow any more character to type in.
So here is the jQuery that you write. If you know that jQuery syntax, then this is not difficult to understand. Text area is what we are looking for with title Reason as list field.
And there you go, try to add more characters in reason and see the result.
So, doesn’t it save your lot of time to write custom field for such a common requirement? Do share your thoughts
SharePoint really provides many of the features out of the boxes. I would say 75% of feature it provides out of the box; however there are some scenarios where these features cannot help us.
Let me give you a classic example. Recently I got a simple requirement. When we create multiline text box in SharePoint, unfortunately there is no option to limit the number of characters in that. It is available in single line of text field but not in multiline text.
Ok, what is the solution? Yes, we can create custom field and ready to go. Yes I agree. But this will take time to create custom field and deploy on the server which may administrator in the company does not give access easily to upload anything.
Hummm…..So what to do? Answer is use jQuery. JQuery is here to save you.
All you have to do is add content editor web part on the page, and just bind keypressed event of textbox and count the number of characters. That is it. So simple. If it exceeds certain number of characters, you popup some message and then do not allow to enter more character in that.
Sounds great. Isn’t it? I know, yes of course.
At least this is far better than developing custom field type and then installs it in server through WSP.
Make sure that you add content editor web part in New Form as well as Edit Form both.
Let us say I have reason filed as multiline textbox in the list and I want to limit number of characters in that 100. We do not want to allow any more character to type in.
So here is the jQuery that you write. If you know that jQuery syntax, then this is not difficult to understand. Text area is what we are looking for with title Reason as list field.
And there you go, try to add more characters in reason and see the result.
So, doesn’t it save your lot of time to write custom field for such a common requirement? Do share your thoughts
No comments:
Post a Comment