I would like to know how can I stop execution of code behind in an aspx page when a jquery function fires:
$(document).ready(function () {
$("#btnSaveProvvisorio").click(function jControllaProvvisorio () {
var i;
var jElemento;
$('.MyTextBoxClass').each(function (i, v) {
jElemento = $(this).val();
if (jElemento) {
if (isNaN(jElemento)) {
alert("Warning: " + jElemento + " is not a number!");
return false;
}
else
if (parseInt(jElemento) <= 0){
alert("Warning: " + jElemento + " is negative!");
return false;
}
}
});
});
});
How can I set the button:
<asp:Button ID="btnSaveProvvisorio" runat="server" style="text-align: center" Text="Salva provvisorio" OnClick="btnSaveProvvisorio_Click" BackColor="#FF6600" ClientIDMode="Static" OnClientClick="jControllaProvvisorio ()"/> ?
This version gives me an error; without the OnClientClick tag the page aspx.cs doesn't stop anyway. Where is the error? Thanks!