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. Advertisements

  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. Advertisements

  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. Advertisements

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. Shawn Mehaffie
    Replies:
    4
    Views:
    870
    Shawn Mehaffie
    Jan 22, 2004
  2. moondaddy
    Replies:
    2
    Views:
    1,228
    Steven Cheng[MSFT]
    Jul 16, 2004
  3. =?Utf-8?B?RHVzdGluIElJLg==?=

    Calling a client side script from server side.

    =?Utf-8?B?RHVzdGluIElJLg==?=, Aug 13, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    8,234
    Levi Rosol
    Aug 16, 2004
  4. Mortar
    Replies:
    4
    Views:
    2,436
    Mortar
    Jan 25, 2005
  5. Magnus Blomberg
    Replies:
    3
    Views:
    1,009
    Magnus Blomberg
    Apr 14, 2005
  6. Boss302
    Replies:
    0
    Views:
    1,372
    Boss302
    Nov 21, 2006
  7. Bogdan
    Replies:
    2
    Views:
    879
    Bogdan
    Jun 9, 2008
  8. Zoe Hart
    Replies:
    1
    Views:
    602
    Scott Wisniewski
    Jan 8, 2004
Loading...