Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate data input on a sharepoint form?

How does one verify a text field with another list's column? I am currently populating a Drop down list with a datasource and then comparing the text field with items in the dropdown using javascript. Is there a better way?

The second problem I am having is how to trigger the Validate Function.

I am aware of two custom forms for adding data to a sharepoint list. One is created using The Dataview Webpart in Sharepoint Designer and the other is created using the List Form Webpart in Sharepoint Designer.

I have a DataFormWebPart I created using Sharepoint Designer Insert Dataview ->Insert Selected Fields as New Item Form. This gives Save and Cancel buttons at the end of the form. How do I intercept the Save button event?

I found one solution but it only works with the NewForm page that has OK Cancel Buttons. http://www.codeproject.com/KB/sharepoint/Control_validation.aspx

like image 412
user24912 Avatar asked Mar 23 '09 21:03

user24912


1 Answers

You'll have to use an event handler if you want to validate the state of multiple fields. You can use the ItemAdding/ItemUpdating events if you want to cancel an item which is being added/updated.

properties.Cancle = true; properties.ErrorMessage = "Your validation message.";

http://msdn.microsoft.com/en-us/magazine/cc163318.aspx

http://blogs.msdn.com/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-you-need-to-know-about-microsoft-office-sharepoint-portal-server-moss-event-handlers.aspx

like image 78
JMD Avatar answered Nov 02 '22 09:11

JMD