Remove alert message

Mehar Naaz
Tera Contributor

MeharNaaz_0-1693890315689.png

Currently this alert is pop on selection of every field in the form, before submitting the form. I want it to pop up on only 1 field when the form is submitted.

any solution to my query?

2 ACCEPTED SOLUTIONS

This script will generate an alert if no Locations is submitted, since you only check if they are equal.

Maybe you should add a check so see if they contain a value first, before evaluating if they are the same?

function onSubmit() {
      var primaryLocation = g_form.getValue('u_primary_location');
    var secondaryLocation = g_form.getValue('u_secondary_location');
  if (primaryLocation || secondaryLocation) {  // added check so see if any location contains a value
        if (primaryLocation == secondaryLocation) {
            alert('Primary Location and Secondary Location cannot be same');
              return false;
        }
  }
}

View solution in original post

MrGupta__
Tera Expert

Hi @Mehar Naaz,

Open the particular form and configure the client script (onChange or onSubmit) for that and check the condition.

Regards,

Himanshu

View solution in original post

8 REPLIES 8

Siva Jyothi M
Mega Sage

Hi @Mehar Naaz,

 

Can you share the script you have written on this

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.

function onSubmit() {
      var primaryLocation = g_form.getValue('u_primary_location');
    var secondaryLocation = g_form.getValue('u_secondary_location');
        if (primaryLocation == secondaryLocation) {
            alert('Primary Location and Secondary Location cannot be same');
              return false;
        }
 
}

@Mehar Naaz

 

Is this the only script written on the form?

 

Mark this answer as correct and helpful if it solves your issue.

 

Regards,

Siva Jyothi M.

 

This script will generate an alert if no Locations is submitted, since you only check if they are equal.

Maybe you should add a check so see if they contain a value first, before evaluating if they are the same?

function onSubmit() {
      var primaryLocation = g_form.getValue('u_primary_location');
    var secondaryLocation = g_form.getValue('u_secondary_location');
  if (primaryLocation || secondaryLocation) {  // added check so see if any location contains a value
        if (primaryLocation == secondaryLocation) {
            alert('Primary Location and Secondary Location cannot be same');
              return false;
        }
  }
}