client side script - cancel submit...

Discussion in 'ASP .Net' started by Iain, Jun 25, 2004.

  1. Iain

    Iain Guest

    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
     
    Iain, Jun 25, 2004
    #1
    1. Advertising

  2. Iain

    Iain Guest

    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
     
    Iain, Jun 25, 2004
    #2
    1. Advertising

  3. Iain

    RSB Guest

    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

    "Iain" <> wrote in message
    news:#...
    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
     
    RSB, Jun 25, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    1
    Views:
    584
    Saravana [MVP]
    Apr 3, 2004
  2. Magnus Blomberg
    Replies:
    3
    Views:
    734
    Magnus Blomberg
    Apr 14, 2005
  3. csgraham74
    Replies:
    5
    Views:
    5,528
    csgraham74
    Jun 14, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,084
    Boss302
    Nov 21, 2006
  5. Bogdan
    Replies:
    2
    Views:
    678
    Bogdan
    Jun 9, 2008
Loading...

Share This Page