Onsubmit catalog client script not working properly

Aindrila Mondal
Tera Expert

Onsubmit catalog client script not working properly. Need to display an errormessage for some specific countries selected on the catalog form & disable the submit button simultaneously. We have written an on submit client script for that where we are checking the condition and then returning false, which seems to work perfectly but only the first time we click on submit button.

If someone modifies to a correct country and then click on onsubmit again, submit functionality doesn't seem to work  and request is not getting raised.

 

snap of the onsubmit script:

AindrilaMondal_0-1665488400916.png

 

Any help regarding the same is appreciated.

 

Thanks,

Aindrila

 

1 ACCEPTED SOLUTION

Yeah that is because, the onsubmit cline script will only when there is a submit action performed on the portal.

 

I would suggest you this:- Change the script to Onchange client script and then if the user select wring country you show them the error message but also clear out the country field using g_form.clearValue('countryvariablename').

 

So this way you will be able to show them the error message and they will also have to select the correct country before proceeding further

 

Please mark my country as correct based on Impact.

View solution in original post

6 REPLIES 6

Anil Lande
Kilo Patron

Hi,

Have you tried adding additional alerts in same script? Please track where exactly it is failing. 

It would be helpful to identify what is happening. Also you can comment the return true; line, it is not required.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I added alerts and the script is working fine the value of the country is also coming correct and all scenarios are working,but only the first time.Like example i select the country 'Russian federation' and click on submit so in this case the error mesaage should come and submit buttom should grey out which is working great.But then without reloading the form if i change the value of the country to say may be'India' for which the request should get submitted, in that case the submit button is still grey out the request is not getting submitted and the onSubmit script is also not getting called .But again if i reload the form anfd then select 'India' and try to submit it works fine then.

Saurav11
Kilo Patron
Kilo Patron

hello,

 

Please apply alert or g_form.addinfomessage to check what value is coming in country everytime and also apply the same inside if and else bracket to check which bracket the code is entering for both the scenarios.

 

Let me know what did you get from the alerts.

 

please mark my answer correct based on Impact

I added alerts and the script is working fine the value of the country is also coming correct and all scenarios are working,but only the first time.Like example i select the country 'Russian federation' and click on submit so in this case the error mesaage should come and submit buttom should grey out which is working great.But then without reloading the form if i change the value of the country to say may be'India' for which the request should get submitted,in that case the submit button is still grey out the request is not getting submitted and the onsubmit script is also not getting called .But again if i reload the form anfd then select 'India' and try to submit it works fine then.