Set Minimum Character Limit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2012 05:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2012 11:43 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 10:06 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 10:39 AM
var limit = //your numeric character limit;
var len = //fieldname.length;
if (len < limit ) {
alert("Enter more characters in the " + fieldname + " field");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2013 12:31 PM
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!