Hiding form elements of sharepoint list with jQuery code

I had a task to editing a sharepoint list and I wanted to edit it with jQuery and\or javascript.

When I opened the list to edit I saw a form with its all of the items. I wanted to change its looks regarding a value of a difference list element. I had to use an ‘If’ statement to perform it.

How looked it like? Like this:

if ($(‘input[value=””]’).length > 0) {
$(‘input[value=””]’).parent().parent().parent().hide();
}

It means that I am looking for an input field with value tag which is empty then it is going to give an array back and I am asking its length with length property tag which is compared with a value. After that I want to hide those fields where the value is empty with the hide() function.

After this code I have edited successfully my list and I saw only that items where the value was not empty. Of course it is working with different conditions too.

(To insert this code snippet it is necessary to add a single (hidden) webpart to your page and edit its “source code”. For more read this: https://letitknow.wordpress.com/2011/03/31/how-to-customize-list-forms-in-sharepoint-2007/)

1 thought on “Hiding form elements of sharepoint list with jQuery code”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s