1

Everything I've read about PreSaveAction requires me to edit the NewForm or EditForm to add the reference into the form. However, given my list is created from Visual Studio using a custom content type and list instance - I don't want to also go down the route of creating a custom form for each of my lists and having to maintain them too.

Any ideas?

  • What are you trying to do on PreSaveAction, maybe you can replace it with Event Receiver or Custom Field Control with Validations ? – Arsalan Adam Khatri Feb 17 '14 at 14:15
2

You don't need to create custom form for your lists. You can create a JavaScript file and override PreSaveAction in it. Then in the Schema file you can add JSLink attribute to to the Form tag in NewForm.aspx or any other form. Example:

<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" JSLink="~site/Scripts/ShowHideField.js" />
  • 1
    I'd gone down the route of using JSLink on the field itself to validate it, I didnt know it could be used on the form itself. – Mauro Feb 17 '14 at 15:29
  • Doesn't look like its working with my version of SP2013/VS2012. JSLink works fine in the CustomField but not in the form tag in schema.xml. – Mauro Feb 17 '14 at 15:56
  • I have used it myself and works well. Make sure you are providing the correct path. – Nadeem Yousuf Feb 17 '14 at 15:58
  • You can also check by setting the Physical path like /_layouts/15/Scripts/ShowHideField.js – Nadeem Yousuf Feb 17 '14 at 16:04
  • I think there was a JS issue, thanks it does work even though VS doesnt like it. – Mauro Feb 17 '14 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.