473,467 Members | 1,514 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CustomValidator not adding error to ValidationSummary

We want to require a value for CboCharity if the value for cboCardSource =
Fundraiser. Here's the client script:

<script language="javascript">
<!--
function ValidateCharity(source, arguments)
{
frmRegister.cboCardSource.IsValid = true;
if (frmRegister.cboCardSource.value == "Fundraiser")
{
if (frmRegister.cboCharity.value == "")
{
frmRegister.cboCardSource.IsValid = false;
}
}
}

//-->
</script>

Here's the CustomValidator:

<asp:customvalidator id="valFundraiser" runat="server"
ErrorMessage="A Fundraiser must be selected" Font-Size="X-Small"
Font-Names="Arial" ControlToValidate="cboCardSource"
ClientValidationFunction="ValidateCharity" Display="None">
</asp:customvalidator>

When the value of cboCardSource = "Fundrasier" and the value of cboCharity =
"" the ValidateCharity client script function runs and cboCardSource.IsValid
is set to false, however the validation summary never includes the error for
cboCardSource: "A Fundraiser must be selected". Why?
Nov 19 '05 #1
1 1487
The arguments parameter contains the IsValid property to set to true or
false. You are setting IsValid on the validator, not arguments.

function ValidateCharity(source, arguments)
{
arguments.IsValid = true;
if (frmRegister.cboCardSource.value == "Fundraiser")
{
if (frmRegister.cboCharity.value == "")
{
arguments.IsValid = false;
}
}
}
--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Luke Morehead" <Luke Mo******@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com... We want to require a value for CboCharity if the value for cboCardSource =
Fundraiser. Here's the client script:

<script language="javascript">
<!--
function ValidateCharity(source, arguments)
{
frmRegister.cboCardSource.IsValid = true;
if (frmRegister.cboCardSource.value == "Fundraiser")
{
if (frmRegister.cboCharity.value == "")
{
frmRegister.cboCardSource.IsValid = false;
}
}
}

//-->
</script>

Here's the CustomValidator:

<asp:customvalidator id="valFundraiser" runat="server"
ErrorMessage="A Fundraiser must be selected" Font-Size="X-Small"
Font-Names="Arial" ControlToValidate="cboCardSource"
ClientValidationFunction="ValidateCharity" Display="None">
</asp:customvalidator>

When the value of cboCardSource = "Fundrasier" and the value of cboCharity
=
"" the ValidateCharity client script function runs and
cboCardSource.IsValid
is set to false, however the validation summary never includes the error
for
cboCardSource: "A Fundraiser must be selected". Why?

Nov 19 '05 #2

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

Similar topics

1
by: Nic | last post by:
hey, is it possible to put the message of the fieldrequiredvalidator (ex. field A is required, please fill in) in the statusbar? normally it comes next to the field, but that is horrible. or maybe...
10
by: Mr. x | last post by:
Hello, I have some code as follows. It seems that customValidator doesn't work - because i don't get any message. In the body : <asp:table> <asp:TableRow>
5
by: Gene McCrory | last post by:
Is it possible to have a CustomValidator against two controls in an EditItemTemplate on a DataGrid? Case: Have a business rule that states if ATextBox starts with "ACertainValue" then BTextBox...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: Tom | last post by:
Hi I need to validate the duplication of username. Here is the aspx code [code <td>User Name:</td><td><asp:textbox id="username" Runat="server"></asp:textbox><asp:requiredfieldvalidator...
1
by: Dorte | last post by:
Hi I am using a customvalidator to perform server validation of user input in webform1. When the user input has been validated, webform1 (which has the customvalidator and the user input) opens a...
3
by: philipl | last post by:
hi, i have a textbox in my edititemtemplate in my datagrid. I have created a customvalidator for it, when i update the row the appropiate function gets called to customvalidate but the problem...
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
1
by: Dan Sikorsky | last post by:
I'm getting the following message when I try to add a CustomValidator control to the ValidationSummary to display an error message at runtime, and displaying ex.message in AddValidationControl...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.