Field validation and field error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:00 AM
Hi ,
I have three fields on new record creation of service portal widget (data table from URL definition) entity, region, country name.
I need to put two validation on country name field are -
1) The 'country name' field Should not have duplicate values for the combination of Entity-Region, otherwise should display below error message: "The Value already exist for the combination Entity-Region".
2) 'Country name' Field Value should not exceed the Max Length otherwise should display below error message: "Field Value exceeds maximum characters.
can someone please help me to achieve this validation on 'country name' field. ??
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:02 AM
Hello @Shivi4 ,
what type of field or input are you using right now ?
is it a custom form in portal ?
if yes can you please send HTML , controller and server code that you wrote and we can enhance the search based on your ask ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:05 AM
Hi @Shivi4 , well it's depends of your Max Length but you can simply build an if condition like "if yourVariable.length >= yourMaxLength" so display your message. You can build that onChange on your Country name field.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:14 AM
Hi @Theo BOULANGER ,
i have did it. but i m not getting the error message onchange of country name filed .
i have written this,
if ((!regtext.test(country_name)) || country_name.length >> 50) {
g_form.showFieldMsg('country_name', 'Field Value exceeds maximum characters.', 'error');
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:11 AM
entity and region are reference type of field from entity and region table and country name is single line text.
I have attached the form it is not a customized form. it is form from the new button of widget 'Data table from URL definition'.