service portal custom widget form validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2022 11:49 PM
hi have one custom widget is there in that multiple input fields are there , for one field if data contains wrong words then on submit the for error message has to come and record should not insert in target table, how can we achieve it
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 04:25 AM
Hi, your exact requirement is not very clear from the question here, however, if you are looking for validation on the data filled in on the form, I think the best approach for that would be using a client script (on- submit) instead of touching the widget code. You can make client script run just on the portal by setting the UI type on the client script form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 05:07 AM
HI
What i have understood from your requirement is you want to put a validation on the field/fields on your custom widget. And whenever there is a wrong information being fed, it should show a error message.
So, here is an example of such validation:
Consider this as sudo code and do necessary changes as per the portal code (modify the element names and other conditions based on your requirement)
experiment this in normal form (fulfiler view)
var decodeVersion=g_form.getValue('decode_version');
var codeSafe=g_form.getValue('code_from_safe');
var patt = new RegExp("^[a-zA-Z0-9_]*$");
var isAlphaNumaric=patt.match(codeSafe);
if(isAlphaNumaric)
{
if(codeSafe.length!=4 && decodeVersion!=5)
alert("Please enter only 4 digits");
if(codeSafe.length!=6 && decodeVersion==5)
alert("Please enter only 6 digits");
}
else
alert("Please do not enter special characters.");
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep