Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 10:15 PM
I think the best solution would be an onChange client script. Have the callback function blank out the field if the server response is invalid. That way since the variable is mandatory and has been blanked out, it won't let you submit.
If you really have to have it onSubmit, do an onChange client script that sets a flag in g_scratchpad to true or false in your callback function, then have your onSubmit check the flag, so there's no AJAX in your onSubmit.
So for the second case, your callback function in your onChange would be:
function callBack(response){
var valResponse = response.responseXML.documentElement.getAttribute("answer");
//or 'valResponse = response;' if you used getXMLAnswer() instead of getXML()
valResponse = valResponse.split(',');
g_scratchpad.validDetails = false;
if(valResponse[0] == '200' || valResponse[0] =='500'){
if(valResponse[1] == 'V'){
g_scratchpad.validDetails = true;
}
}
}
Then have an onSubmit client script:
function onSubmit() {
if(!g_scratchpad.validDetails) {
alert("Please enter correct Accounting Details");
return false;
}
}