Over the last few days i have read a lot of forum about custom validator not working or not firing etc. I am stuck in a similar situation and of all the solutions i have come across they dont seem to be working for me.
I have a contact us form on my site (ASP.NET, AJAX, VB) and I need to validate the textbox input on most of the inputs i have use requiredfieldva lidator, expressionvalid ators and they all work alright. What i also need to do is to change the colour of the invalid textboxes. thus I am using custom validator
the following code in the validate script -
Protected Sub cvPhone_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
-
-
MsgBox("I am here")
-
'If phone.Text = "111111111" Then
-
'phone.CssClass = "txtErr"
-
'phone.Text = cvPhone.ErrorMessage
-
'args.IsValid = False
-
'Else
-
'phone.CssClass = "normal"
-
'args.IsValid = True
-
'End If
-
-
End Sub
-
Call in the textbox -
<div id="col2"><asp:TextBox ID="phone" CssClass="normal" runat="server"></asp:TextBox></div>
-
<div id="row">
-
<%--<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4"
-
ControlToValidate ="phone" ErrorMessage="Please enter Phone Number"
-
Display="Dynamic" Font-Size="12px" ForeColor="silver"></asp:RequiredFieldValidator>
-
<asp:RegularExpressionValidator ID="phoneExp" runat="server"
-
ControlToValidate="phone" ErrorMessage="Not a valid phone number, Must be 10 digits"
-
Font-Size="12px" ForeColor="silver" Display="Dynamic"
-
ValidationExpression="^\d{10}$"></asp:RegularExpressionValidator>--%>
-
<asp:CustomValidator ID="cvPhone" ControlToValidate="phone" runat="server" Display="none" ErrorMessage="Invalid phone" OnServerValidate="cvPhone_ServerValidate"></asp:CustomValidator>
"I have also tried to remove the controltovalida te clause, used clientvalidatio nfunction, have also tried page.validate under the submit button, did if page.isvalid then 'do whatever'
but none of the above seem to be able to fire the custom validate clause.
The Submit button -
<asp:Button ID="Submit" runat="server" Text="Submit" OnClick="Submit_Click" CausesValidation="true" />
on click this runs a Send Email script.
Since I am using AJAX these controls are under updatepanel...
Appreciate any help guys!!!!
0 1207 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike P |
last post by:
I have a Custom validator that has ControlToValidate set to a textbox
that also has a Required and RegularExpression validator.
When I run the webpage on my machine the custom validator
OnServerValidate procedure is only called if both the Required and
RegularExpression validators are successfully met.
However, when I upload the page to my live website, if I enter an
invalid value in the textbox (i.e. one that doesn't meet the...
|
by: Evgueni |
last post by:
Hello,
I am new to .NET, and a custom validator is giving me a lot of grief.
I want to use a Custom Validation control and for some reasons it's not firing the validation procedure. I am using .NET framework 1.0
Here is the declaration of the control
<asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 103; LEFT: 304px; POSITION: absolute; TOP: 408px" runat="server" ErrorMessage="Bad input -- please correct"...
|
by: pmud |
last post by:
Hi,
I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-...
|
by: Mattyw |
last post by:
Hi,
I'm relatively new to Web Forms, I have been using Required Field
Validators and Regular Expression Validators on a Web Form I am
developing and everything works as expected using Visual Studio.NET
2003 and VB code behind.
I have a radio button and textbox, and basically i need the textbox to
be required based on the user selecting "Yes" from the radio button.
I've read through the newsgroups and found that a Custom Validator
|
by: Alan Silver |
last post by:
Hello,
I have a custom validator on my page, and have the server-side code
working fine. I want to add a client-side funtion as well, but am not
sure how to wire it in so that it works with the other validators on the
page.
I specified the name of the Javascript function with the
ClientValidationFunction attribute of the custom validator, and it is
being called fine. However, if the validator returns false (ie bad
| |
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 lot of research in the
areas of XHTML and WAI compliance, and am attempting to come up with a
recommendation for our product in terms of standards level compliance.
Ideally, I would like to be at XHTML 1.0 Strict.
However, in my reading I have...
|
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, even if I force the
customvalidator to validate by invoking its validate() method after a
button is clicked:
cvCustomValidator_ServerValidate(object source,
system.Web.UI.WebControls.ServerValidateEventArgs args) <== doesn't get
|
by: tsw_mik |
last post by:
I have created a custom control. It has:
-label
-button
-list of textboxes
-list of dropdownlists.
I want to use a custom validator to perform some validation, but
somehow I can't fo it. The code looks like this:
public class ColumnSelector : Panel
{
|
by: Rick |
last post by:
Hello,
I built a composite web control that has a textbox and a date
control.
added my custom control on a webform where there are other standard
controls.
Each control on the form has a required validator.
I need to have a validator for my custom control, but don't know how
to do this.
I added a CustomValidator to the form, but in design mode, my custom
|
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 Validation Callout Extender with the custom validators its not working properly.
here is the link where i got solution for one custom validator with validation callout extender :-
http://www.junnark.com/Articles/Article0001.aspx
I searched a lot but...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |