Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom list with below two columns. 1. Choice with Yes/No values 2. Multiple lines of text

In New Item form of this list, on click of save button I want to make field 2 mandatory only when "Yes" is checked in field 1. Please let me know how can i achieve this and please excuse me for such a novice question, I am really very new in sharepoint. Thanks in advance.

share|improve this question

migrated from stackoverflow.com May 10 '12 at 10:07

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 2 down vote accepted

An event Receiver would indeed a possible solution here.You'd then override the ItemAdding event checking the Checkbox field value if yes and textbox is empty then cancle event firing and return false. Something like this:

  properties.Cancel = true;
  properties.ErrorMessage = "Item Must Required";
  properties.Status = SPEventReceiverStatus.CancelWithError; 

Let me know if u done with this.

share|improve this answer
    
I am sorry but i am very new in Sharepoint and I also have been told that custome coding not allowed so i am really not able to follow your answer. :( –  NotesArt May 10 '12 at 9:30
1  
Ok according to you are able to use javascript then see this solution ghamson.wordpress.com/2011/01/25/… social.technet.microsoft.com/Forums/en-US/… –  Vishal_Sharepoint May 10 '12 at 9:43

In list settings you can only set, that field is either required or not.

To do some more advanced logic, you probably would need to create Custom Field, and write your own validation based on values from another field.

Use of Event Receivers is of course another way.

share|improve this answer
    
Thanks for your answer, could you please provide some more information? Right now i am using PreSaveAction() function and in this function i am taking handle of the fields by id, took id from the web page source. also let me know if it is not a good way of doing this.. –  NotesArt May 10 '12 at 8:58

Unfortunately multiple lines of text fields are not allowed in formulars.

If you can change Field2 to a single line of text then you can add a validation saying =OR(NOT(Field1),Field2>"")

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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