Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Suppose I have 2 Radio Button and and 4 textbox and 1 Button If i 1st radio button is select then it allow 3rd and 4th textbox allow to be null.(it fire validation on textbox 1 and textbox 2) and if i select radio buttoon 2 then it allow 1st and 2nd textbox allow to be null (it fire validation on textbox 3 and textbox 4)
its whole happend when i Click on Button .Please help Me.
Thanks in Advance
Posted 10-Dec-12 23:27pm
Edited 11-Dec-12 0:35am
choudhary.sumit at 11-Dec-12 5:35am
are you working on web application or a desktop application?
hardy panchal at 11-Dec-12 7:13am
I am working on Web Application
shabari7 at 11-Dec-12 7:14am
********Assumptions:WebForm,individual radio buttons with same groupname,one is checked by default. code behind, in !ispostback btnSubmit.attributes.add("onclick","return javascript:fnValidate()"); in aspx script tag function fnValidate() { var radTwo = document.getelementbyid('radOneid'); var txtOneId = document.getelementbyid('txtOneId'); var txtTwoId = document.getelementbyid('txtTwoId'); var txtThreeId= document.getelementbyid('txtThreeId'); var txtFourId= document.getelementbyid('txtFourId'); if(radTwo.checked) { if(txtThreeId.value=="" && txtFourId.value=="") { alert('Text 3 and 4 are required'); return flase; } } else { if(txtOneId.value=="" && txtTwoId.value=="") { alert('Text 1 and 2 are required'); return false; } } }
Milind_T at 11-Dec-12 7:17am
@shabari7: Why in comment, please post as solution.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

if($('#txt3').val()=="" ||$('#txt4').val()=="")
alert('This textbox should not be null');
else if($('#rbt2').is('checked')==true)
if($('#txt1').val()=="" ||$('#txt2').val()=="")
alert('This textbox should not be null');

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Sergey Alexandrovich Kryukov 840
1 OriginalGriff 508
2 Abhinav S 278
3 thatraja 225
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,142
1 OriginalGriff 4,665
2 Peter Leow 3,774
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107

Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid