How to validate one of two Required TextBox

Discussion in 'ASP .Net Web Controls' started by Gilles Lambert, Apr 14, 2005.

  1. Hi,

    I've to require a value in either of two TextBox. I tried with the
    CustomValidator with the function :

    function MobTel(source, args) {
    if ( Form1.txtTelephone.value == "" && Form1.txtMobile.value == "" ) {
    args.IsValid = false;
    return;
    }
    }
    args.IsValid = true;
    return;
    }

    But the function is not called at all despite the fact it is affected to
    the Property ClientValidationFunction of the control to validate.

    Should i implement the server validation or is it a way to proceed this
    kind of validation ?

    Thanks and best regards
    Gilles


    *** Sent via Developersdex http://www.developersdex.com ***
    Gilles Lambert, Apr 14, 2005
    #1
    1. Advertising

  2. Gilles Lambert

    Brock Allen Guest

    What browser are you using? The client side validation only is supposed if
    the browser is IE. You should always implement a server validation function
    for this reason.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi,
    >
    > I've to require a value in either of two TextBox. I tried with the
    > CustomValidator with the function :
    >
    > function MobTel(source, args) {
    > if ( Form1.txtTelephone.value == "" && Form1.txtMobile.value == "" )
    > {
    > args.IsValid = false;
    > return;
    > }
    > }
    > args.IsValid = true;
    > return;
    > }
    > But the function is not called at all despite the fact it is affected
    > to the Property ClientValidationFunction of the control to validate.
    >
    > Should i implement the server validation or is it a way to proceed
    > this kind of validation ?
    >
    > Thanks and best regards
    > Gilles
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
    Brock Allen, Apr 14, 2005
    #2
    1. Advertising

  3. I'm using IE6, with client scripts enabled. Ok for the server
    validation, but i don't understand why the function is not called ?



    *** Sent via Developersdex http://www.developersdex.com ***
    Gilles Lambert, Apr 14, 2005
    #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. Nicolas
    Replies:
    0
    Views:
    603
    Nicolas
    Dec 3, 2003
  2. Luigi
    Replies:
    3
    Views:
    535
    Luigi
    Nov 27, 2009
  3. agb

    writing two textbox's text in one textbox

    agb, Aug 26, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    166
    Ken Cox [Microsoft MVP]
    Aug 27, 2003
  4. Ray

    Validate only one textbox value

    Ray, Jan 31, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    103
  5. Meredith
    Replies:
    1
    Views:
    119
    Meredith
    Feb 11, 2005
Loading...

Share This Page