I have 2 <asp:textbox controls>:
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them
shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You must
insert text1 or text2!"
ControlToValidate="txt2"
Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
valPhone.ServerValidate
If txt1.Text = "" And txt2.Text = "" Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
The server validation is fired only if there is some value in txt2 box.If
txt2.text is empty then server validation is not fired.
How can I solve this problem?
I would like also to include client validation.
Thank you,
Simon 3 2333
Hi Simon,
An empty field is a valid input for a custom validator! I think there
is the possibility to leave the ControlToValidate field blank, but I
haven't tried it yet.
See: http://msdn.microsoft.com/library/de...pplusvalid.asp
Regards
Johannes
On Thu, 27 May 2004 09:55:32 +0200, "simon"
<si*********@stud-moderna.si> wrote: I have 2 <asp:textbox controls>:
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You must insert text1 or text2!" ControlToValidate="txt2" Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs ) Handles valPhone.ServerValidate If txt1.Text = "" And txt2.Text = "" Then args.IsValid = False Else args.IsValid = True End If End Sub
The server validation is fired only if there is some value in txt2 box.If txt2.text is empty then server validation is not fired. How can I solve this problem?
I would like also to include client validation.
Thank you, Simon
Try getting rid of the ControlToValidate property. It's not necessary
for a CustomValidator, and in this case, it may be what is preventing
the ServerValidate event from firing.
For client-side validation, use the ClientValidationFunction property
of the CustomValidator.
"simon" <si*********@stud-moderna.si> wrote in message news:<#9**************@TK2MSFTNGP09.phx.gbl>... I have 2 <asp:textbox controls>:
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You must insert text1 or text2!" ControlToValidate="txt2" Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles valPhone.ServerValidate If txt1.Text = "" And txt2.Text = "" Then args.IsValid = False Else args.IsValid = True End If End Sub
The server validation is fired only if there is some value in txt2 box.If txt2.text is empty then server validation is not fired. How can I solve this problem?
I would like also to include client validation.
Thank you, Simon
Hi,
If I get rid of the ControlToValidate property then validation function is
executed but when I set
args.isValid=false, nothing happened.
It just pass by like if I set args.isValid=true.
No difference.
Any idea?
Thank you,
Simon
"DujHoD" <J2********@aol.com> wrote in message
news:76**************************@posting.google.c om... Try getting rid of the ControlToValidate property. It's not necessary for a CustomValidator, and in this case, it may be what is preventing the ServerValidate event from firing.
For client-side validation, use the ClientValidationFunction property of the CustomValidator.
"simon" <si*********@stud-moderna.si> wrote in message
news:<#9**************@TK2MSFTNGP09.phx.gbl>... I have 2 <asp:textbox controls>:
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You
must insert text1 or text2!" ControlToValidate="txt2" Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args
As System.Web.UI.WebControls.ServerValidateEventArgs) Handles valPhone.ServerValidate If txt1.Text = "" And txt2.Text = "" Then args.IsValid = False Else args.IsValid = True End If End Sub
The server validation is fired only if there is some value in txt2
box.If txt2.text is empty then server validation is not fired. How can I solve this problem?
I would like also to include client validation.
Thank you, Simon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Barbara Alderton |
last post by:
I setup some standard Required Field Validation controls and one Custom
validation control on an ASP.NET page (within a user control) to validate
text entry. I also setup a Summary Control to post...
|
by: Stephen Adam |
last post by:
Hi there,
I have written a custom validation control which checks to see of an input
field is not empty and contains only numeric data. I was using a regular
expression validation control but...
|
by: |
last post by:
Hi all,
Has anyone been able to write some custom javascript on the onclick event of
submit button to do certain things like disable submit button, only submit
form once etc. This was a breeze...
|
by: wardy1975 |
last post by:
Hi All,
Looking for a little expert advice on a few web standards issues. I am
currently trying to understand the impact of web standards for a web
application I work with. I have been doing a...
|
by: Marek |
last post by:
Hi all,
I have custrom control with four elements: text box, regular expression
validator, required field validator and custom validator. Next this control
is dragged on to web site with several...
|
by: Andy |
last post by:
Hi folks,
I have a customvalidator control that works properly if it isn't
contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I
find that _ServerValidate doesn't get fired,...
|
by: gagandeepgupta16 |
last post by:
Hi
I am working on an entry form using validation controls in ASP.NET.
I have two controls which requires custom validators, no issue in using plain custom validators.
But when i am using...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: asharda |
last post by:
I have a custom property grid. I am using custom property grid as I do
not want the error messages that the propertygrid shows when abphabets
are entered in interger fields.
The custom property...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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: 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,...
| |