client side script - cancel submit...

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
 
I

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
 
R

RSB

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top