Sharepoint provide facility to implement validation in the
list through validation settings option which exist in the list setting. However,
this validation does exist for new and edit forms. There are some situations
when you want to implement different validation for different form. In such
cases you can implement client site script for validation.
In the below example on the calendar list business want to
implement following validation:-
- In the new form user can create event for present or future date. That means the start date should be greater than now.
- In the edit form user should be able to edit the date to past date but should not edit it to before created date. That means Start date should be greater than created date.
You can leverage below code snippet to implement validation
mention in point 1 for new form. Edit
newform.aspx and add a script editor web part. Put below snippet in the script
editor web part.
You can leverage below code snippet to implement validation
mention in point 2 for edit form. Edit editform.aspx and add a script editor web
part. Put below snippet in the script editor web part.
No comments:
Post a Comment