Monday, February 8, 2016

URL validation in sharepoint through javascript

In SharePoint 2013 there are cases when you would like to validated client side URL and prompt user if it is invalid URL. Below code snippet can be used for this validation. Edit newform.aspx and editform.aspx, place a script editor webpart with following code snippet. You can alternatively created feature and on feature activation event add script edit, inject this js code.



Calendar new form and edit form date validation in SharePoint 2013 through javascript


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.