- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 04:42 AM
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:
Any help regarding the same is appreciated.
Thanks,
Aindrila
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 05:16 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 04:53 AM - edited ‎10-11-2022 04:55 AM
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.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 05:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 04:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2022 05:05 AM
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.