You can cancel an AJAX request in a client script function simply by
returning
false value. For example:
function CheckZipCode()
{
var zipCode = document.getElementById('<%=TextBox1.ClientID%>').value;
if (zipCode.length != 5)
{
alert('Please enter a valid 5 digit postal code!');
return false; // cancel the AJAX request
}
else
{
var fiveDigitCheckRE=/^\d{5}$/ //regular expression for checking a 5 digit number
if (zipCode.search(fiveDigitCheckRE) == -1)
{
alert("Only digits are allowed!"); return false;
}
}
}
This functionality can be applied also to the standart javascript confirm box
which returns true/false to confirm/cancel the AJAX request.
More about confirmation and AJAX could be found here:
RadAjax help -> Client-Side -> How-To -> Client confirmation and AJAX