none
How to put mandatory field to multiple lines of text RRS feed

  • Question

  • Hi..., Am putting required to my column which is having multiple line of text. it is showing error message when am not giving any data. if am giving space's in the multiple lines of text field is not showing any error message ... can  any one tell solution for this....  

    how to show error message when am giving spaces in the field.... i tried based on id by using trim() function


    Bhavya Sruthi

    Monday, March 20, 2017 10:49 AM

All replies

  • Hi

    you can't use multiple lines field in calculation columns and/or validation condition at list level

    You can use Infopath to define editform.aspx and newform.aspx which will check if that field contains only

    or customize you editform and NewForm  pages with sharepoint designer, and inside them put a javascript code which will use regular expression to verify specific field

    Please check this solution

    http://stackoverflow.com/questions/2662245/how-to-check-whether-the-input-text-field-contains-only-white-spaces


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Monday, March 20, 2017 11:09 AM
  • Hi... am not using any calculations for the column am just taking multiple lines of text on provided required for that column... and am using trim() function in editform.aspx and newform.aspx ... but it is not recognizing.

    I had tried in this way..

    $("#Description_3d7e947e-236e-45bd-8fd3-521c295dd41d_$TextField_topDiv").val().trim();

    but it is showing syntax error it is not recognizing the id of the 'div'.......


    Bhavya Sruthi

    Monday, March 20, 2017 12:26 PM
  • hi

    calculated column and valiadtion could be an easiest way.

    ...  div's ID is dynamically allocated.  Try to identify it using another way - manual ID or his class


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Monday, March 20, 2017 12:56 PM
  • Hi Bhavya,

    Please add the following code into a content editor web part in the new/edit form page.

    <script src="http://code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function PreSaveItem(){
    	if($("div[id^='Description_'][id$='TextField_inplacerte']").text().trim()=="​"||$("div[id^='Description_'][id$='TextField_inplacerte']").text().trim()==""){
    		if($("span[id^='Error_Description']").length==0){
    			$("div[id^='Description_'][id$='TextField_topDiv']").after("<span class='ms-formvalidation ms-csrformvalidation' id='Error_Description'>You can't leave this blank.<br></br></span>");
    		}
    		return false;
    	}
    	return true;
    }
    </script> 

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Proposed as answer by KaviyaMVP Tuesday, March 21, 2017 12:23 PM
    Tuesday, March 21, 2017 9:04 AM
    Moderator