1

I have a custom list in which some specific fields need to have additional validation which I am implementing through Validation Settings.

However, on the Validation Settings page, when I go to create my formula, the option to add in the columns that I have already formatted as Multiple Lines of Text do not appear in the list of columns to chose from.

Does anyone know why specifically a Multi Lines columns seem to be missing from the validation settings? If I change the format from Multi Lines to Single Line of Text, for example, it appears in the list, however, I do need the column to be a Multi Line format.

Thanks in advance.

1 Answer 1

3

Multi-line text field is not available in column picker of Validation Settings page since it is not supported in formula expressions. But you could consider the following client-side approach.

How to validate Multi-line text field in SharePoint

Probably one of the best ways to apply client-side validation in SharePoint 2010 and 2013 would be to override PreSaveAction handler.

PreSaveAction function is a user defined function that allows to override standard behavior for a Save button handler in List Forms on the client-side.

Let's say we need to validate Notes field in Links list to accept only letters, then the following steps demonstrate how to apply those changes:

Steps:

  1. Open New Form page in Edit mode
  2. Add Content Editor web part on the page
  3. Insert the code provided below into Content property of Content Editor web part

Code:

<script>
function isLetter(val) { 
    var re = /^[a-zA-Z]+$/;
    return re.test(val);
} 


function PreSaveAction(){

    var commentsBox = findFieldControl('Notes');  //find field control by title
    if (!isLetter(commentsBox.val())) {
        var errorHtml = '<br/><span class="ms-formvalidation"><span role="alert">Only letters are allowed<br></span></span>';
        commentsBox.after(errorHtml);
        return false;
    }
    return true;
}

function findFieldControl(fieldTitle)
{
    var control = $('[title="' + fieldTitle + '"]');
    return control;
}

</script>​​​​​​

Result

enter image description here

Some additional information about client-side validation in SharePoint 2010/2013 could be found in this post.

2
  • I checked your your solution, but it doesnt Change anything. I changed the title 'Notes' to 'Input' like it is titeled in my list. Do I have to Change anything more? Thanks in advance, Tobias
    – Tobias
    Jun 25, 2015 at 7:24
  • @Tobias, could you create a separate question by specifying what have you tried and what does not work? Jun 25, 2015 at 8:20

Your Answer

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

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