I have 1 text box - Textbox1
2 Radiobuttons - Rb1,Rb2.
my problem is
if i select Rb1- Textbox1 accept only numeric values.
Rb2 selected - Textbox2 accept alphanumeric values only
plz help me
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 4, 2015, 6:24 PM EST
Hi AKSHAY HARSHA,
Use a CustomValidator that implements it's own regular expression logic based on a conditional operator. In other words:
public void someCustomValidator(object obj, ServerValidateEventArgs e)
{
}
For regular expression go through following article
http://www.c-sharpcorner.com/UploadFile/ee01e6/important-list-of-regular-expressions-and-its-uses/
Rajagopalan R VRank #6,801 · 256 reputationPosted Jan 4, 2015, 6:32 PM EST
AKSHAY HARSHA.,
In Your aspx Page
<td>
<asp:TextBox ID="tbx1" runat="server" Visible="false">asp:TextBox>
<asp:TextBox ID="tbx2" runat="server" Visible="false">asp:TextBox>
<td>
<asp:RadioButtonList ID="radioButton1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged=" radioButton1_SelectedIndexChanged">
asp:RadioButtonList>
td>
<td>
<asp:RadioButtonList ID="radioButton2" runat="server" AutoPostBack="true"
OnSelectedIndexChanged=" radioButton2_SelectedIndexChanged">
asp:RadioButtonList>
td>
In Your cs Page
protected void radioButton1_SelectedIndexChanged(object sender, EventArgs e)
{
tbx1.Visible=true;
tbx2.Visible=false;
}
protected void radioButton2_SelectedIndexChanged(object sender, EventArgs e)
{
tbx1.Visible=false;
tbx2.Visible=true;
}
RakeshRank #520 · 4.7K reputationPosted Jan 4, 2015, 7:25 PM EST
RakeshRank #520 · 4.7K reputationPosted Jan 5, 2015, 4:40 AM EST
AKSHAY HARSHA36 reputationPosted Jan 5, 2015, 1:53 AM EST
Could you plz explain with example.. i need it
AKSHAY HARSHA36 reputationPosted Jan 5, 2015, 1:55 AM EST
i have only 1 textbox with 2 radiobuttons..
your code is working while two texboxes with 2 radiobuttons.
plz understand my question and give reply