how to set the minimum length of a single line text in sharepoint online?
-
07-02-2021 - |
Вопрос
I have already set the maximum length, but now I need the user to enter not less than a certain amount
This is the script I'm using :
function PreSaveAction() {
var control = getElementByID("IBAN(24 Digits Alpha Numeric)");
if(control.value.length < 24)
{
alert("The length in this field should not be less than 24 chars");
return false; // Cancel the item save process
}
else { return true ;}
}
Решение
SharePoint OOTB Solution:
Use Column Validation:
- Go to your list settings.
- Click on your text column.
Move to column validation section and enter below expression:
=LEN([your column name])>24
And you can enter some message in user message section.
JavaScript Approach:
Try using below code:
Assuming the display name of your field is "IBAN(24 Digits Alpha Numeric)".
var control = document.querySelector("input[title^='IBAN(24 Digits Alpha Numeric)']");
Другие советы
Please try below code to get the control element:
var control = WebForm_GetElementById("IBAN(24 Digits Alpha Numeric)");
Не связан с sharepoint.stackexchange