Question

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 ;}
}
Was it helpful?

Solution

SharePoint OOTB Solution:

Use Column Validation:

  1. Go to your list settings.
  2. Click on your text column.
  3. 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)']");

OTHER TIPS

Please try below code to get the control element:

var control = WebForm_GetElementById("IBAN(24 Digits Alpha Numeric)");
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top