The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Set Minimum Character Limit

Dan Tolgyesi1
Tera Expert

Hi,

I was just wandering if anyone knows how to set a minimum character limit on a string field. I know you can set a maximum length limit using the system dictionary .

This is to prevent users from puting just a "." or a space in the field etc.

Any help is appreciated.

Thanks
Dan

8 REPLIES 8

geoffcox
Giga Guru

You could add an onChange client script that would check the length, and if too short, warn the user and then clear the field and put the cursor back in the field. The "mandatory" setting can be used to prevent them from saving with the empty field.

Do you need help with the script?


Hi,

This is actually something I am after, how do you write the script so that it checks the characters in the field and if not enough, alert user?

Thanks.

Alex



var limit = //your numeric character limit;
var len = //fieldname.length;
if (len < limit ) {
alert("Enter more characters in the " + fieldname + " field");
}


geoffcox
Giga Guru



var myFieldValue = g_form.getValue('your_field');
if (myFieldValue.toString().length < 3) { // or whatever number you want
g_form.setValue('your_field','');
alert('Please enter 3 or more characters.');
}


Please remember to mark your question as answered if this meets your need. Thanks!