This article is documenting how we can achieve the following:

  • Validate input in a client script asynchronously.
  • Prevent the form submit until the input is valid.
  • Submit the form when the input has been validated.

How did it use to work?

In a nutshell, many platform Ajax requests used getXMLWait().
getXMLWait() would make a synchronous request to the server and cause script execution to wait until the server responded.

Using ajax in an onSubmit script was as easy as:

  1. Executing the request
  2. Validating the response
  3. Returning true or false

Validate before onSubmit in Mobile/Service Portal

Since all framework Ajax requests are asynchronous you will need to use a callback like in this onSubmit script:

function onSubmit() {
if (g_scratchpad.isFormValid)
return true;
var actionName = g_form.getActionName();
doAsyncTask(function() {
g_scratchpad.isFormValid = true;
return false;

Article Information

Last Updated:2019-09-24 09:02:01