473,785 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change the RegularExpressi onValidator's ValidationExpre ssion at cl

I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressi onvalidator to evaluate the value of textbox.

EIN must be (for simplicity) with this format (2 digits) like 12 (ValidationExpr ession="\d{3}-\d{2}")

and SIN must be (for simplicity) with this format (3digits-2digits) like 123-45 (ValidationExpr ession="\d{3}-\d{2}")

It works well. The problem is: When I change the redio buttons selection, I do not want page to be refreshed. What is the right way?

I have used Microsoft validation controls in all pages so I want to generate the same format error message if I need to bypass the validations controls.

I put all the aspx.cs and asp code at the end of this email.

Please help. Thanks for your help.

Regards

Andy Eshterayeh

This is the ASPX.CS file

private void RadioButtonList 1_SelectedIndex Changed(object sender, System.EventArg s e)

{
if(RadioButtonL ist1.SelectedVa lue.Equals("1") ) //THIS IS EIN

{
ExpSSN.Enabled = false;

ExpSSN.Visible = false;

ExpEIN.Enabled = true;

ExpEIN.Visible = true;

}

if(RadioButtonL ist1.SelectedVa lue.Equals("2") ) //THIS IS SSN

{
ExpEIN.Enabled = false;

ExpEIN.Visible = false;
ExpSSN.Enabled = true;

ExpSSN.Visible = true;

}

}

private void Button1_Click(o bject sender, System.EventArg s e)

{

Response.Redire ct("rblist.aspx ");

}

This is the ASPX file

<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:RadioButto nList id="RadioButton List1" style="Z-INDEX: 101; LEFT: 264px; POSITION: absolute; TOP: 192px"
runat="server" AutoPostBack="T rue" RepeatDirection ="Horizontal " Width="376px">
<asp:ListItem Value="1">EIN (12)</asp:ListItem>
<asp:ListItem Value="2">SSN(1 23-45)</asp:ListItem>
</asp:RadioButton List>
<asp:validation summary id="valfrmCusto merInfo" style="Z-INDEX: 107; LEFT: 352px; POSITION: absolute; TOP: 96px"
Runat="server" DisplayMode="Bu lletList" ForeColor="#ff0 066"></asp:validations ummary>
<asp:requiredfi eldvalidator id="ReqSSNEINRb tn" style="Z-INDEX: 106; LEFT: 192px; POSITION: absolute; TOP: 256px"
runat="server" ControlToValida te="RadioButton List1" Display="None" ErrorMessage="P lease select SSN or EIN Number "></asp:requiredfie ldvalidator>
<asp:regularexp ressionvalidato r id="ExpSSN" style="Z-INDEX: 104; LEFT: 200px; POSITION: absolute; TOP: 328px" ControlToValida te="TextBox1"
Display="None" ErrorMessage="P lease fill in a valid SSN Number" Enabled="False" ValidationExpre ssion="\d{3}-\d{2}"
Visible="False" Runat="server"> Please fill in a valid SSN Number</asp:regularexpr essionvalidator >
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 440px; POSITION: absolute; TOP: 376px" runat="server"
Text="Button"></asp:Button>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 376px; POSITION: absolute; TOP: 256px"
runat="server"> </asp:TextBox>
<asp:regularexp ressionvalidato r id="ExpEIN" style="Z-INDEX: 105; LEFT: 192px; POSITION: absolute; TOP: 296px" runat="server"
ControlToValida te="TextBox1" Display="None" ErrorMessage="P lease enter a valid EIN Number" Enabled="False" ValidationExpre ssion="\d{2}"
Visible="False" >Please enter a valid EIN Number</asp:regularexpr essionvalidator >
</form>
</body>

Nov 16 '05 #1
0 3016

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1281
by: Mark Dengler | last post by:
I'm hoping this is simple. All I want to do is to make sure that a / (slash) is not entered into a text box. here are some of my failed attempts: ValidationExpression="\w" ValidationExpression="\w" ValidationExpression="^/" ValidationExpression="" ValidationExpression="w"
0
2259
by: Shan Plourde | last post by:
Hi everyone, I have been using various regular expressions with the ASP.NET RegularExpressionValidator for quite some time. In general it works very well. One of the common regex's that I use follows: ValidationExpression = "^\d{0,3}(\.\d{0,4})?$" The purpose of this one is to validate that numeric values input follow the syntax 999.9999. This works well. But, one thing that I have never tested previously (which has now been uncovered...
3
3682
by: tshad | last post by:
I have a RegularExpressionValidator that doesn't seem to work correctly if you don't enter anything. In the following, it works correctly if you have at least 1 character. If you just enter through the field it lets you (even thoug no entry would be less that 6 characters. <asp:textbox id="password1" TextMode="Password" Columns="45" runat="server" /><asp:label text=" 6-20 characters with at least 1 numeric" style="color:red"...
1
1849
by: franz | last post by:
does anybody tell me why it doesn't works?? in any case gg beame true thanks franz Dim y As RegularExpressionValidator = New RegularExpressionValidator y.ValidationExpression = "^\w+(\w+)*@\w+(\w+)*\.\w+(\w+)*$" y.ControlToValidate = "ss5ssss" Dim gg As Boolean = y.IsValid
9
3931
by: Nathan Sokalski | last post by:
I have several TextBoxes with TextMode="MultiLine" in which I want to limit the number of characters that can be entered using a RegularExpressionValidator. I have come up with the following ValidationExpression: {0,250} The only problem with this ValidationExpression is that it does not include the \n character as stated on the following documentation page:
0
1888
by: Morten71 | last post by:
I have this regex. in the ValidationExpression property of my dotnet 1.1 RegularExpressionValidator control: ^(?i)(DF)?+$ However, I can't make the ignore case part (?i) work! How should I construct my regex / RegularExpressionValidator to ignore case?
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.