Field validation and field error message

Shivi4
Tera Contributor

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 !

8 REPLIES 8

Mohith Devatte
Tera Sage
Tera Sage

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 ?

Theo BOULANGER
Giga Guru

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,

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;
}

Shivi4
Tera Contributor

hi @Mohith Devatte 

                                                                                                                                                                                                    country_name.png 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'.