473,585 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

customValidator doesn't work

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 >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>
....

In the script :

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false, but even this doesn't
work.
End sub
</script>
....

What is wrong in my code ?

Thanks :)
Nov 18 '05 #1
10 4751
Could be you're using <asp:Table>, which is server side, not client side.
Change it to a standard HTML <table> and the validator should work.
"Mr. x" <a@b.com> wrote in message
news:e2******** ******@TK2MSFTN GP10.phx.gbl...
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 >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>
...

In the script :

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false, but even this doesn't
work.
End sub
</script>
...

What is wrong in my code ?

Thanks :)

Nov 18 '05 #2
Your codes shows that you are using a RequiredFieldVa lidator not a
CustomValidator as this post's subject implies. Which is it?
"Mr. x" <a@b.com> wrote in message
news:e2******** ******@TK2MSFTN GP10.phx.gbl...
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 >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>
...

In the script :

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false, but even this doesn't
work.
End sub
</script>
...

What is wrong in my code ?

Thanks :)

Nov 18 '05 #3
There is one of each... He must've figured it out as he hasn't replied to
either post.
"Scott M." <s-***@BADSPAMsnet .net> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Your codes shows that you are using a RequiredFieldVa lidator not a
CustomValidator as this post's subject implies. Which is it?
"Mr. x" <a@b.com> wrote in message
news:e2******** ******@TK2MSFTN GP10.phx.gbl...
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 >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>
...

In the script :

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false, but even this doesn't
work.
End sub
</script>
...

What is wrong in my code ?

Thanks :)


Nov 18 '05 #4
> There is one of each... He must've figured it out as he hasn't replied to
either post.

Well,
It's good somebody notice that I have both RequiredFieldVa lidator and
CustomValidator .
(I have checked also without RequiredFieldVa lidator - the same result).

Still, I didn't resolve the problem, and I am still waiting for kind a
solution, please.

Thanks :)
Nov 18 '05 #5
Mr. x wrote:
There is one of each... He must've figured it out as he hasn't replied to
either post.


Well,
It's good somebody notice that I have both RequiredFieldVa lidator and
CustomValidator .
(I have checked also without RequiredFieldVa lidator - the same result).

Still, I didn't resolve the problem, and I am still waiting for kind a
solution, please.


Your code as originally posted seems to work fine for me - I did have to
add a few overhead-type tags to get ASP.NET to accept the file (@Page,
the form tag, etc.), but otherwise I simply pasted in what you posted.

Here's exactly what I placed into an IIS application directory in test.aspx:
=============== =============== =============== =============== ===========
<%@ Page language="VB" debug="false" %>

<html>
<head>
</head>
<body>
<form runat="server">
<asp:table>

<asp:TableRow >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false
End sub
</script>

</form>
</body>
</html>
=============== =============== =============== =============== ===========

If you still have the problem with this exact aspx file, you might want
to run a repair installation for your .NET Framework.

--
mikeb
Nov 18 '05 #6
Mr. x wrote:
Look at the attachment file, and see that customValidator doesn't work - why
?
You need to test for the validity of the page in your
sendContactMess age() button click handler.

Put the following lines at the top of sendContactMess age():

If Not Me.IsValid Then
Return
End If

and I think you'll get the behavior you want.
For details, see:
http://msdn.microsoft.com/library/en...mmatically.asp


(Also - it's for .net, and I don't know whether it is bug on .net or not,
but when I validate this file on :
http://validator.w3.org, it seems to be wrong, because of .net).

Thanks :)

"mikeb" <ma************ @mailnull.com> wrote in message
news:ON******** *****@tk2msftng p13.phx.gbl...
Mr. x wrote:

There is one of each... He must've figured it out as he hasn't replied
to
either post.

Well,
It's good somebody notice that I have both RequiredFieldVa lidator and
CustomValida tor.
(I have checked also without RequiredFieldVa lidator - the same result).

Still, I didn't resolve the problem, and I am still waiting for kind a
solution, please.


Your code as originally posted seems to work fine for me - I did have to
add a few overhead-type tags to get ASP.NET to accept the file (@Page,
the form tag, etc.), but otherwise I simply pasted in what you posted.

Here's exactly what I placed into an IIS application directory in


test.aspx:
============= =============== =============== =============== =============
<%@ Page language="VB" debug="false" %>

<html>
<head>
</head>
<body>
<form runat="server">
<asp:table>

<asp:TableRow >
<asp:TableCel l>
<asp:RequiredFi eldValidator
ControlToValida te="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell> email:</asp:TableCell>
<asp:TableCell> <asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>

<asp:TableRow >
<asp:TableCel l>
<asp:CustomVali dator
ControlToValida te="a_email"
OnServerValidat e="checkEmail "
Text="Illegal"
ErrorMessage="I llegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>

</asp:Table>

<script runat = "server">
Sub checkEmail(sour ce As object,args As ServerValidateE ventArgs)
args.IsValid=fa lse 'just testing - always false
End sub
</script>

</form>
</body>
</html>
============= =============== =============== =============== =============

If you still have the problem with this exact aspx file, you might want
to run a repair installation for your .NET Framework.

--
mikeb


--
mikeb
Nov 18 '05 #7
"mikeb" <ma************ @mailnull.com> wrote in message
news:Od******** ******@tk2msftn gp13.phx.gbl...
Mr. x wrote:
Hello,
I am Eitan, and I use sometimes Mr. X as nick-name in newsgroups.
Look at the attachment file, and see that customValidator doesn't work - why ?


You need to test for the validity of the page in your
sendContactMess age() button click handler.

Put the following lines at the top of sendContactMess age():

If Not Me.IsValid Then
Return
End If

and I think you'll get the behavior you want.


I did as you said If Not Me.IsValid Then
Return
End If

)
and now it's almost O.K.
When everythiing is typed correctly I get no message - that's OK.

When the e-mail is typed wrong,
I get the message of ValidationSumma ry :
Fields with astarisks are must.

I don't want to get this message in every case my input is wrong.
How can I do that ?

Look at my code for :
<asp:Validation Summary
HeaderText="Fie lds with astarisks are must"
DisplayMode="Bu lletList"
EnableClientScr ipt="true"
runat="server"/>

Thanks :)
Nov 18 '05 #8
Eitan wrote:
"mikeb" <ma************ @mailnull.com> wrote in message
news:Od******** ******@tk2msftn gp13.phx.gbl...
Mr. x wrote:

Hello,
I am Eitan, and I use sometimes Mr. X as nick-name in newsgroups.

Look at the attachment file, and see that customValidator doesn't work -
why
?


You need to test for the validity of the page in your
sendContactMe ssage() button click handler.

Put the following lines at the top of sendContactMess age():

If Not Me.IsValid Then
Return
End If

and I think you'll get the behavior you want.

I did as you said
If Not Me.IsValid Then
Return
End If


)
and now it's almost O.K.
When everythiing is typed correctly I get no message - that's OK.

When the e-mail is typed wrong,
I get the message of ValidationSumma ry :
Fields with astarisks are must.

I don't want to get this message in every case my input is wrong.
How can I do that ?

Look at my code for :
<asp:Validation Summary
HeaderText="Fie lds with astarisks are must"
DisplayMode="Bu lletList"
EnableClientScr ipt="true"
runat="server"/>

Thanks :)


Well, the HeaderText property of the ValidationSumma ry control is just
that - a header that's displayed whenever the validation summary is
displayed. You should set it to a more generic message, or you could
dynamically set it in a Page_Load handler that examines all the
validation controls in the Page.Validators collection and see which ones
failed to create an appropriate message.

But it would probably be simpler to have HeaderText be a generic header,
and set the ErrorMessage and Text properties for the various validators
so that appropriate messages are displayed in the appropriate locations.

--
mikeb
Nov 18 '05 #9
"mikeb" <ma************ @mailnull.com> wrote in message
Well, the HeaderText property of the ValidationSumma ry control is just
that - a header that's displayed whenever the validation summary is
displayed. You should set it to a more generic message, or you could
dynamically set it in a Page_Load handler that examines all the
validation controls in the Page.Validators collection and see which ones
failed to create an appropriate message. Can you give me some examples of page_load, please ?
But it would probably be simpler to have HeaderText be a generic header,
and set the ErrorMessage and Text properties for the various validators
so that appropriate messages are displayed in the appropriate locations.


I'll check this out, but ...
What generic, i.e ?
Is "There was an error on the following fields" good enough ?
Are there any examples for that ?

What if I several fields that are required fields - for them I want one
generic message.
and two fields that are not required, but not written correctly
(CustomValidato r return false) - for them I want each one to have one
message at summary.
How can I do that ?

Thanks :)
Nov 18 '05 #10

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

Similar topics

5
3153
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 value is required. I added a CustomValidator to the EditItemTemplate for the column containing BTextBox. I did not set the ControlToValidate, but...
3
1748
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server. As it is client side scripting I'm suprised that this is the case as I'm using the same browser IE6 and the same machine to access both. I've...
1
1817
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 ValidationSummary. Now I want to check the username should contain only chatacters, ( I want to use customvalidator), when i enter char+number it trap the event...
1
2682
by: Vi | last post by:
Hi, I have two pairs of a DropDownList and TextBox Controls and for each pair I have a CustomValidator that makes sure that at least one of the two (DropDownList or TextList) has a value. When I submit the form, the OnServerValidate method for the first pair of controls (DropDownList and TextList) fires, but for the second pair does not. It...
1
3289
by: Ricky Williams | last post by:
I have a CustomValidator for a Radio Button that works fine with IE, but doesn't trigger with Firefox or Netscape. I have been stuck on this one for 3 weeks; any suggestions greatly appreciated. Thanks! <script language="javascript"> function ValidateRadiobutton(oSrc, args) {
1
2483
by: Beffmans | last post by:
Hi I have defined an customvalidator on my TextBox: function clientvalidate(source, arguments){ { // even number? if (arguments.Value%2 == 0) arguments.IsValid = true; else
1
1008
by: RTT | last post by:
It's my first time i want to write a cotum validator but it doesn't seem to work. In de page i've put this validator: <asp:CustomValidator id="CVFBeginDate" OnServerValidate="CVFBeginDate_ServerValidate" runat="server" ErrorMessage="Please fill in a valid date as startdate" ControlToValidate="TxtBeginDate">*</asp:CustomValidator> in de...
1
1465
by: Jason Chan | last post by:
wroten following aspx in VWD 2005 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled...
3
2861
by: Stan SR | last post by:
Hi, I have a web user control that contains 3 dropdownlists it's a date selector, so one contains the days, one the months and the last the years. Each of them starts with a blank value. I want to control if the date is valid or blank (that means all the dropdownlist have a blank value).
0
8195
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8334
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8209
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...
0
6596
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...
1
5707
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5386
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...
0
3831
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...
1
2340
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
0
1171
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...

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.