- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 11:24 AM
Hi,
I need to restrict the first name and last name fields more than 15 letters
Can you help me on script?
Thanks in Advance!!
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 01:28 PM
Can you please try
g_form.addErrorMessage Instead of showErrorBox.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 12:37 PM
Try I think this will work.
function onSubmit() {
var firstName = g_form.getValue('field_name').length;
var lastName = g_form.getValue('field_name').length;
var result = firstName+lastName;
if(result > 15){
g_form.showFieldMsg('Enter less than 15 characters ', 'error', true);
return false;
}
}
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 12:40 PM
and you can use different type of messages through scripting
Scripting alert, info, and error messages
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 12:58 PM
Hi Yousaf,
I have created onsubmit client script
Now I am not able to submit the request and the error message also not showing!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 01:01 PM
Please add info message before if like
g_form.addInfoMessage(result);
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-21-2022 01:16 PM
Hi Yousaf,
I have added that add info before if
I am not able to see the error message
When I have given less than 15 characters i am able to submit if I am giving greater than 15 I am not able to submit but i am not able to see the error message