- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 11:37 AM
Hello everyone,
I have a question regarding catalog item. I would like to abort the submission of a catalog item if a given field is not a number. I know it can be done in client script if I am not mistaken, but I don't know what should the code look like.
if (isNaN(newValue) == true) is the first step, but I don't know what are the next steps in order to abort the submission.
Thank you for your help in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 11:43 AM
You need to use an onSubmit client script and it needs to return false in order to abort the form submission. Try this:
if (isNaN(g_form.getValue('your_field_name')))
return false;
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 11:43 AM
You need to use an onSubmit client script and it needs to return false in order to abort the form submission. Try this:
if (isNaN(g_form.getValue('your_field_name')))
return false;
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2021 11:49 AM
Hello, you can try creating a client-side script from your catalog item form. You can do this by the context menu as shown below.
Then you click the New button and set type field to onSubmit. To avoid item to be send if a certain condition is not meet, you can try something like
if(!condition){//note that i am checking for false result
g_form.addInfoMessage('A message to indicate the error');
return false;
}
You can also use g_form.addErrorMessage() to set a message more clear.