473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Re field validation

Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".

I have got two radio buttons No and Yes and text box that has to be fiiled
in only if Yes is clicked. How can I validate this?

Here is a code:

<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>

<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" />
<!--- here I need some type of validation if a user cliked Yes --->

Help is very much appreciated!

Thanks
Nov 18 '05 #1
4 1418
Also, I am using VB

"News" <ge**@mailcity.com> wrote in message
news:y9********************@magma.ca...
Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".

I have got two radio buttons No and Yes and text box that has to be fiiled
in only if Yes is clicked. How can I validate this?

Here is a code:

<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>

<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" />
<!--- here I need some type of validation if a user cliked Yes --->

Help is very much appreciated!

Thanks

Nov 18 '05 #2
Can you do something like this:

1. Add a button.
2. Add this code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If is_override.SelectedValue = 1 And reason.Text = "" Then
Response.Write("You must enter a reason!")
Else
' do whatever (redirect, etc...)
End If
End Sub

"News" <ge**@mailcity.com> wrote in message
news:Gf********************@magma.ca...
Also, I am using VB

"News" <ge**@mailcity.com> wrote in message
news:y9********************@magma.ca...
Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".

I have got two radio buttons No and Yes and text box that has to be fiiled in only if Yes is clicked. How can I validate this?

Here is a code:

<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>

<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" /> <!--- here I need some type of validation if a user cliked Yes --->

Help is very much appreciated!

Thanks


Nov 18 '05 #3
None of the Microsoft validators have the ability to turn themselves on
based on another element of the page. There are two solutions.

1. Write a custom validator. If you want it to work on the client side, you
will have to figure out that code too.

2. I have written a replacement for Microsoft's validation, "Professional
Validation And More" (http://www.peterblum.com/vam/home.aspx). Each of its
validators has a new property, "Enabler", where you can define a rule that
smartly enables the validator. On my RequiredTextValidator, you can set the
Enabler to look at the radiobutton before enabling itself. This works fully
on the client-side. In fact, Professional Validation And More's 22
validators support many more browsers on the client-side than Microsoft: IE,
IE/Mac, Netscape/Mozilla, Opera 7 and Safari.

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

"News" <ge**@mailcity.com> wrote in message
news:y9********************@magma.ca...
Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".

I have got two radio buttons No and Yes and text box that has to be fiiled
in only if Yes is clicked. How can I validate this?

Here is a code:

<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>

<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" />
<!--- here I need some type of validation if a user cliked Yes --->

Help is very much appreciated!

Thanks

Nov 18 '05 #4
None of the Microsoft validators have the ability to turn themselves on
based on another element of the page. There are two solutions.

1. Write a custom validator. If you want it to work on the client side, you
will have to figure out that code too.

2. I have written a replacement for Microsoft's validation, "Professional
Validation And More" (http://www.peterblum.com/vam/home.aspx). Each of its
validators has a new property, "Enabler", where you can define a rule that
smartly enables the validator. On my RequiredTextValidator, you can set the
Enabler to look at the radiobutton before enabling itself. This works fully
on the client-side. In fact, Professional Validation And More's 22
validators support many more browsers on the client-side than Microsoft: IE,
IE/Mac, Netscape/Mozilla, Opera 7 and Safari.

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

"News" <ge**@mailcity.com> wrote in message
news:y9********************@magma.ca...
Hi,
I am new to asp.net and unfortunately, have to learn as I go.
Here is a "problem".

I have got two radio buttons No and Yes and text box that has to be fiiled
in only if Yes is clicked. How can I validate this?

Here is a code:

<asp:radiobuttonlist RepeatDirection=Horizontal RepeatLayout=Table
id="is_override" runat="server">
<asp:listitem text="No" Value="0"></asp:listitem>
<asp:listitem text="Yes" Value="1"></asp:listitem>
</asp:radiobuttonlist>
<asp:requiredfieldvalidator
id="RequiredFieldValidator_is_override"
runat="server"
ErrorMessage="You must choose a valid Override option."
ControlToValidate="is_override">
</asp:requiredfieldvalidator>

<asp:textbox size=50 MaxLength="100" id="reason" runat="server" Text="" />
<!--- here I need some type of validation if a user cliked Yes --->

Help is very much appreciated!

Thanks

Nov 18 '05 #5

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

Similar topics

3
by: Shabam | last post by:
I know that dotnet allows for form field validation. However I'm looking to customize the error message display and am wondering if it's possible to do what I need. Example: Suppose in a...
2
by: Doslil | last post by:
I am trying to validate the fields in my database.I have already validated the fields to check for not null.Here is what I have written for Numeric and text field. Private Function EENUM() On...
2
by: Joey P | last post by:
Hi all, I am doing a project for university whereby i have to implement a simple database related to a frozen foods company. I am having some trouble though creating a validation rule for one...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
3
by: Kivak Wolf | last post by:
Hi, Could someone give me a quick review of how to use the required field Validator? I'm completely at a loss, and MSDN does not help one bit. =/ Basically all I want done is to make sure that...
1
by: Niclas | last post by:
Hi, How do I indicate what field fails a validation, usually you see a red star next to the faild field on a form. Is this built in functionality in the valdaition controls or shall I code this...
1
by: AECL_DEV | last post by:
Hello Everyone, Ive seen alot of people saying that the best way to AJAX Validate a form is through the submit button, because validation should be synchronous. Im wondering, is there any good...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.