PC Review


Reply
Thread Tools Rate Thread

CustomValidator doesn't give error message

 
 
COHENMARVIN
Guest
Posts: n/a
 
      5th Aug 2005
I have a customValidator that calls a client function.
Here is the client function
<script language="JavaScript">
function ClientValidate(objSource, objArgs)
{
var intnumber = objArgs.Value;
if (intnumber > 5)
{
objArgs.IsValid = False;
return False;
}
Else
{
objArgs.IsValid = True;
return True;
}
}
</script>

Here is the CustomValidator:

<ASP:CustomValidator id="valCustom" runat="server"
ControlToValidate = "MyTextBox"
ClientValidationFunction="ClientValidate"
ErrorMessage="* Value must be less than or equal to 5 "
Display="Dynamic">
*
</asp:CustomValidator>

The problem is that the custom validator puts a red asterix next to the
textbox field even when the number entered into the textbox is valid.
It treats all numbers as wrong. Another problem involves the
ValidationSummary control (see below)

<ASP:ValidationSummary id="valSummary" runat="server"
ShowSummary="True"
ShowMessageBox = "True" DisplayMode="List" HeaderText = "<b>The
following errors were found</b>" />

This should give an error message when the value in "MyTextBox" is
wrong, but it doesn't.
-- CohenMarvin

 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      5th Aug 2005
Hi Marvin,

I read your other thread first. I believe your best answer is to use the
CompareValidator, Type=Integer, ValueToCompare=5, Operator=GreaterThan.

But to offer some insight on this problem, here are my thoughts:
1. objArgs.Value contains a string. Let's convert it to an integer first:
var intnumber = parseInt(objArgs.Value);

2. Don't return true or false. The result is always set in objArgs.IsValid
(which you've done). So just remove those return statements.

--- Peter Blum
www.PeterBlum.com
Email: (E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"COHENMARVIN" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a customValidator that calls a client function.
> Here is the client function
> <script language="JavaScript">
> function ClientValidate(objSource, objArgs)
> {
> var intnumber = objArgs.Value;
> if (intnumber > 5)
> {
> objArgs.IsValid = False;
> return False;
> }
> Else
> {
> objArgs.IsValid = True;
> return True;
> }
> }
> </script>
>
> Here is the CustomValidator:
>
> <ASP:CustomValidator id="valCustom" runat="server"
> ControlToValidate = "MyTextBox"
> ClientValidationFunction="ClientValidate"
> ErrorMessage="* Value must be less than or equal to 5 "
> Display="Dynamic">
> *
> </asp:CustomValidator>
>
> The problem is that the custom validator puts a red asterix next to the
> textbox field even when the number entered into the textbox is valid.
> It treats all numbers as wrong. Another problem involves the
> ValidationSummary control (see below)
>
> <ASP:ValidationSummary id="valSummary" runat="server"
> ShowSummary="True"
> ShowMessageBox = "True" DisplayMode="List" HeaderText = "<b>The
> following errors were found</b>" />
>
> This should give an error message when the value in "MyTextBox" is
> wrong, but it doesn't.
> -- CohenMarvin
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a formula that doesn't give a #VALUE! error Maury Markowitz Microsoft Excel Programming 2 26th Jan 2009 04:33 PM
CustomValidator doesn;t work =?Utf-8?B?SmFzb24gQ2hhbg==?= Microsoft ASP .NET 1 17th May 2006 05:54 PM
Modifying a customValidator error message from the client function? Damon Microsoft ASP .NET 1 18th Mar 2006 02:58 AM
WindowsXP Frequently Restarts doesn't give any error tutor4me@gmail.com Windows XP Setup 3 31st Dec 2005 08:51 AM
CustomValidator Doesn't Run on FireFox Steve Murphy Microsoft ASP .NET 7 3rd Aug 2005 06:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:10 AM.