3

SharePoint 2010 and unable to use SharePoint Designer

Form:

Users answer a yes/no question in one column, then provide a name in another column. The people picker column is only required when the previous column is 'Yes'.

Failure Mode:

If a user selects 'Yes', the people picker column can be left blank and no one is notified.

Want:

To add column validation so that if 'Yes' is selected and there is no information in the people picker column, the user cannot save the form and notifies the user why.

Progress:

So far I am planning on adding a content editor webpart to form entry with a script. The problem is I cannot get the script to function (I only know what I can google)

2 Answers 2

0

Try something like this SHOW / HIDE FIELDS BASED ON CHOICE FIELD SELECTION USING JQUERY IN SHAREPOINT.

A section of the code:

if ($("select[title='City']").val() != "other")
{
$('nobr:contains("OtherCity")').closest('tr').hide();
$('nobr:contains("Field2")').closest('tr').hide();
}
else {
$('nobr:contains("OtherCity")').closest('tr').show();
$('nobr:contains("Field2")').closest('tr').show();}

Result 1:

enter image description here

Result 2:

enter image description here

0

There is a function called PreSaveAction() in sharepoint that your can override. It will execute after the save button is clicked and only complete the save if you return true.

function PreSaveAction(){
    var flag = true;

    if(!condition){
      //validation failed
      //highlight a field red or do an alert
      flag = false;
    }

    return flag;

 }

You can try to link something like. The only problem is I am not sure about the load order of this script if you try to link it in a webpart. Its worth a shot though, it is how custom form validation is intended to be used in SharePoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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