简体   繁体   中英

Apply Type validation on Sharepoint list columns

I have a dropdown list having list of all the columns present in a Sharepoint xyz list. Below is my code.

function getColumnname() 
{ 

var _fields = ''; 
var lEnum = fields.getEnumerator(); 
var fieldxList = document.getElementById('ddlxField');
$('#ddlxField').find('option:gt(0)').remove();


while(lEnum.moveNext()) 

{ 
    _fields = lEnum.get_current().get_title();
    var newListItem = document.createElement('OPTION'); 
    var box = _fields;
    newListItem.text = box;
    newListItem.value = box;
    fieldxList.add(newListItem);
    box.value = "";
 } 

 } 
<div>
 <select id="ddlxField"></select></div>

Now, what I want is to apply validation on this dropdown , so that user can choose only those column , whose type="Single line of text", if he chooses column name of some other type , it should prompt. Is that possible?

It should be achievable by adding the onchange event handler for your dropdownlist.

You will have to save the field title to column type mapping in an array/object, and refer it in your validation logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM