PC Review


Reply
Thread Tools Rate Thread

CustomValidator does not work

 
 
Beffmans
Guest
Posts: n/a
 
      8th Aug 2005
Hi

I have defined an customvalidator on my TextBox:

function clientvalidate(source, arguments){
{
// even number?
if (arguments.Value%2 == 0)
arguments.IsValid = true;
else
arguments.IsValid = false;
}


<asp:TextBox id="txtNumber" Runat="server" width="62px"></asp:TextBox>
<asp:CustomValidator id="custvalNumber" runat="server"
ErrorMessage="Number is not even" ControlToValidate="txtNumber"
ClientValidationFunction="clientvalidate">*</asp:CustomValidator>

what could I be doing wrong?

ch B.



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Tom.PesterDELETETHISSS@pandora.be
Guest
Posts: n/a
 
      8th Aug 2005
> function clientvalidate(source, arguments){
> {


There are 2 { in the above code. Only one is allowed. This works for me :

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<script>
function clientvalidate(source, arguments)
{
// even number?
if (arguments.Value%2 == 0)
arguments.IsValid = true;
else
arguments.IsValid = false;
}
</script>

<asp:TextBox ID="txtNumber" runat="server" Width="62px"></asp:TextBox>
<asp:CustomValidator ID="custvalNumber" runat="server" ErrorMessage="Number
is not even"
ControlToValidate="txtNumber" ClientValidationFunction="clientvalidate"
Height="218px"
Width="300px">*</asp:CustomValidator><asp:Button
ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>


Let me know it helped you or not...

Cheers,
Tom Pester

> Hi
>
> I have defined an customvalidator on my TextBox:
>
> function clientvalidate(source, arguments){
> {
> // even number?
> if (arguments.Value%2 == 0)
> arguments.IsValid = true;
> else
> arguments.IsValid = false;
> }
> <asp:TextBox id="txtNumber" Runat="server" width="62px"></asp:TextBox>
> <asp:CustomValidator id="custvalNumber" runat="server"
> ErrorMessage="Number is not even" ControlToValidate="txtNumber"
> ClientValidationFunction="clientvalidate">*</asp:CustomValidator>
>
> what could I be doing wrong?
>
> ch B.
>
> *** Sent via Developersdex http://www.developersdex.com ***
>



 
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
Can't use asp:CustomValidator K Viltersten Microsoft ASP .NET 5 24th Mar 2009 09:16 AM
customvalidator do not work with empty fields Eric Layman Microsoft ASP .NET 4 28th Mar 2007 02:58 AM
CustomValidator doesn;t work =?Utf-8?B?SmFzb24gQ2hhbg==?= Microsoft ASP .NET 1 17th May 2006 05:54 PM
Using CustomValidator anony Microsoft ASP .NET 2 24th Sep 2004 03:19 PM
customValidator doesn't work Mr. x Microsoft ASP .NET 10 16th Dec 2003 12:41 AM


Features
 

Advertising
 

Newsgroups
 


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