client side script - cancel submit...

  • Thread starter Thread starter Iain
  • Start date Start date
I

Iain

I have an <asp:ImageButton ...> which I do some client side validation with
by adding an Attribe for the on click.

How do I tell asp NOT to submit if my function does not validate? I've
tried returning false but to no avail.

I'm sure it's obvious when I know how!

Iain
 
Thanks RSB.

Returning False should work. as i am using this.
Are you execute another function in the Click function .. if yes make sure
that you are returning the False in the Click Function.
function submitVoucher(thisImg, textName)
{
theImage = thisImg;
var elVC = getElement(textName);
if (VoucherIsOK(elVC))
{
return true;
}
else
{
if (elVC.value.length <17)
alert('You have not entered enough characters for a Voucher
Code.\n Please check and enter again carefully.');
else
alert('You have entered an invalid Voucher Code.\n Please check
and enter again carefully.');
return false;
}
}

is my js function and

GoButton.Attributes.Add("onClick", "submitVoucher(this, '" +
VoucherCode.ClientID + "');");

is how I'm getting it there.

Should this be OK?

Iain
 
Hi Iain,

Returning False should work. as i am using this.
Are you execute another function in the Click function .. if yes make sure
that you are returning the False in the Click Function.

RSB

I have an <asp:ImageButton ...> which I do some client side validation with
by adding an Attribe for the on click.

How do I tell asp NOT to submit if my function does not validate? I've
tried returning false but to no avail.

I'm sure it's obvious when I know how!

Iain
 
Back
Top