Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Onsubmit client script needs to return false , when child function returns false

Uttam Sai
Tera Expert

Hi All,

 

I am trying below onsubmit client script , when the functions(verifystartdate(response) and verifyenddate(response)) inside onsubmit return false , i want onsubmit function to return false so that the form is prevented from updating or committing.

 Kindly suggest if this is possible.

1 REPLY 1

Uttam Sai
Tera Expert

Client Script:

function onSubmit() {
//g_form.clearMessages();
var num = g_form.getReference('task_number',func);
var beginDate = g_form.getValue("begin");
var endDate = g_form.getValue("end");
function func(num)
{
if(num.number.toString().indexOf('CHG')>-1)
{
var ga = new GlideAjax('ChangeRequestCheckBeginDate'); //client callable script include
ga.addParam('sysparm_name', 'checkStartofChange'); //function name on the script include
ga.addParam('outageStartDate', beginDate); // the begin date selected by the user
ga.addParam('changeId', g_form.getValue('task_number')); //changeID - to query and compare with the change start date.
ga.getXML(verifystartdate);
}

}


function verifystartdate(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'false'){
//alert('Outage Begin date should be within the Change Planned Window');
g_form.addErrorMessage(getMessage("Outage Begin date should be within the Change Planned Window"));
//g_form.showFieldMsg('begin','Outage Begin date should be within the Change Planned Window','error');
//g_form.clearValue('begin'); //to clear out the value selected by the user
return false;
}

}

var num1 = g_form.getReference('task_number',func1);
function func1(num1)
{
if(num1.number.toString().indexOf('CHG')>-1)
{
var ga = new GlideAjax('ChangeRequestCheckEndDate'); //client callable script include
ga.addParam('sysparm_name', 'checkendofChange'); //function name on the script include
ga.addParam('outageendDate', endDate); // the begin date selected by the user
ga.addParam('changeId', g_form.getValue('task_number')); //changeID - to query and compare with the change start date.
ga.getXML(verifyenddate);
}
}

function verifyenddate(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'false'){
//alert('Outage End date should be within the Change Planned Window');
g_form.addErrorMessage(getMessage("Outage End date should be within the Change Planned Window"));
//g_form.showFieldMsg('end','Outage End date should be within the Change Planned Window','error');
//g_form.clearValue('end'); //to clear out the value selected by the user
return false;
}

}


}