Pregunta

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 ;}
}
¿Fue útil?

Solución

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)']");

Otros consejos

Please try below code to get the control element:

var control = WebForm_GetElementById("IBAN(24 Digits Alpha Numeric)");
Licenciado bajo: CC-BY-SA con atribución
scroll top