1

We have a Travel Reason Choice/Checkboxes (allow multiple selections) column with values:

  1. Conference
  2. Customer Visit
  3. Site Visit
  4. Summit
  5. Training

We also have date fields for each of these travel reasons.

The default validation option for the list won't pick up this column type.

How can we validate for any of the checked items + verify if the appropriate date is filled in?

So, if they check Conference, Site Visit and Training (since a travel session could cover all 3), we need to verify they have the dates populated (other columns) for these 3 travel types.

********Update: choice field + date validation solved with code below, but now default SharePoint validation doesn't outline required fields.

    <script type="text/javascript">        
function PreSaveAction() {
var myCheckbox = $('#Travel_x0020_Type_a16cb653-3c2e-4065-b2ba-eace5d2ef1cd_MultiChoiceOption_0');
var chkTraining = $('#Travel_x0020_Type_a16cb653-3c2e-4065-b2ba-eace5d2ef1cd_MultiChoiceOption_4');            
var checkedConf = $(myCheckbox).is(":checked");  //is Conference checkbox checked (true/false)?
var checkedTraining = $(chkTraining).is(":checked");  //is Training checkbox checked (true/false)?          
var calConfStartDateEmpty= $('#Conference_x0020_Travel_x0020_De_74ff820f-5e96-4d0c-a5f3-bc704b401af8_\\$DateTimeFieldDate').val().length === 0;
var calConfEndDateEmpty = $('#Conference_x0020_End_x0020_Date__69dfc50f-5a3f-4a2f-96ef-d7b2c4ba8757_\\$DateTimeFieldDate').val().length === 0;
var calTrainingStartDateEmpty= $('#Training_x0020_Start_x0020_Date__ff2bd66a-57cc-47f5-b27f-43d7d14ab089_\\$DateTimeFieldDate').val().length === 0;
var calTrainingEndDateEmpty = $('#Training_x0020_End_x0020_Date_x0_cfa76e5e-3cb4-49d2-8918-e96dfb7379f3_\\$DateTimeFieldDate').val().length === 0;

if (checkedConf == true)
{if (calConfStartDateEmpty == true || calConfEndDateEmpty == true)
alert("If Conference Travel Reason is selected, please make sure both Conference Dates are populated");}

if (checkedTraining == true)
{if (calTrainingStartDateEmpty == true || calTrainingEndDateEmpty == true)
alert("If Training Travel Reason is selected, please make sure both Training Dates are populated");}   
}    
</script>
0

Unfortunately, your requirements can't be achieved using List Validation Settings!

The Choice field with Checkboxes (allow multiple selections) is not allowed in the SharePoint Validation Settings and the Calculated field.

For more details, check The Supported and Unsupported Columns In SharePoint Calculated Column Formula / Validation Settings


Workaround

  • Switch to a Radio button or drop-down list to can use it in the Validation Settings.
  • Build your custom form using custom code to can match your business requirements.
  • I was able to get the validation functionality, but the problem is now the default SharePoint check for required fields doesn't fire and outline the fields in red showing which fields are required. Is there any way around this? – Sol Web Solutions Aug 7 '18 at 14:24
  • Are you sure you can use Checkboxes (allow multiple selections in the Validation settings!! based on your answer, we can search for a way around :) Please Confirm! – Mohamed El-Qassas MVP Aug 7 '18 at 14:32

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.