Here is the code that I'm applying, it does give an alert box but as soon as I click on ok rather than letting me edit the mistake it takes me to the next page. How do I stop redirection?
Qualtrics.SurveyEngine.addOnReady(function()
{
var that = this;
jQuery("#NextButton").hide();
jQuery("#NextButton").after('');
var txtEntry = jQuery("input[id*='QR~QID'][type='text']");
jQuery("#CustomNextButton").click(function() {
var v1 = parseInt(txtEntry.eq(0).val());
var v2 = parseInt(txtEntry.eq(1).val());
var v3 = parseInt(txtEntry.eq(2).val());
var v4 = parseInt(txtEntry.eq(3).val());
var v5 = parseInt(txtEntry.eq(4).val());
var v6 = parseInt(txtEntry.eq(5).val());
var v7 = parseInt(txtEntry.eq(6).val());
var v8 = parseInt(txtEntry.eq(7).val());
var v9 = parseInt(txtEntry.eq(8).val());
var vtot1 = v2 + v3 + v4 + v5 - v6;
var vtot2= v1 - vtot1;
if (vtot2 != v7)
{ alert("Please enter the correct figures, Balance at 31 december = Balance at 1 January - Leavers during the year (resignation, retrenchments, dismissed, retirements + Number of new joiners) ");}
else { that.clickNextButton();}
var per_staff= v8;
var temp_staff= v9;
var total_temp_per_staff = per_staff + temp_staff;
if (total_temp_per_staff != v7)
{ alert("Please enter the correct figures, Balance at 31 december = Permanent Staff + Temporary Staff ");
}
else { that.clickNextButton();}
});
});
Best answer by Eumetis
View original