|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to validate one of two Required TextBoxI'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 *** 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 *** > 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 *** 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 *** 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 ***
Customizing ASP.NEt Hyperlink Control
Need Click Event to Fire from TextBox custom validator and button events Urgent! GridView and templated controls binding---------Plz help Defining server-side Click event for Label web contol ? TemplateControl?? Creating a Tab in web form Textboxes with images Windows Explorer style custom control for web make a button deault |
|||||||||||||||||||||||