SPUtility to set , hide and make field readonly in EditForm and NewForm

I was trying to work out how to set, hide and make fields read-only in EditForm.aspx and NewForm.aspx depending on conditions.

I stumbled on SPUtility.js library from

https://sputility.codeplex.com/

It allows to manipulate fields on EditForm.aspx and NewForm.aspx

Set a Text field’s value

SPUtility.GetSPField(‘Title’).SetValue(‘Test Set Field’);

Set a Text field’s value to today’s date and make it read only

var date = new Date();

SPUtility.GetSPField(‘Date Realised’).SetDate(date.getFullYear(), date.getMonth() + 1, date.getDate()).MakeReadOnly();

Hide a field from view

SPUtility.GetSPField(‘test hide’).Hide();

Advertisements

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