Home All Groups Group Topic Archive Search About

How to validate one of two Required TextBox

Author
14 Apr 2005 2:13 PM
Gilles Lambert
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 ***

Author
14 Apr 2005 2:46 PM
Brock Allen
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



Show quoteHide quote
> 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 ***
>
Author
14 Apr 2005 2:57 PM
Gilles Lambert
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 ***
Author
14 Apr 2005 10:02 PM
Peter Blum
Javascript function names are case sensitive. Your function name is MobTel.
Did you use that exact string in the same case in the
ClientValidationFunction?

--- Peter Blum
www.PeterBlum.com
Email: PLB***@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

Show quoteHide quote
"Gilles Lambert" <gnto***@hotmail.com> wrote in message
news:O4k6$IQQFHA.1392@TK2MSFTNGP10.phx.gbl...
> 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 ***
Author
16 Apr 2005 7:18 AM
Gilles Lambert
In fact, i forget that a validate control don't work if the field to
validate is empty. This still not resolve my problem because i d'ont
want to add a RequiredFieldValidator on each Field : I really don't see
how to do on client side ...

Best regards
Gilles



*** Sent via Developersdex http://www.developersdex.com ***