473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

CustomControl - Not triggering on an empty field.


Hi,

I've made a serverside component that automatically adds a validator.
Currently i have both a REQUIRED validator and a CUSTOM validator in it.

The customValidator has a javascript function that checks the value and if the
value is bad it makes the control RED.
(All done client side)

My problem now is that i also want to do that with fields that are required.

So i have two options:

Extend the requiredvalidator somehow so it will also change the color of
controls.

or

Somehow get the CustomValidator to trigger when fields are empty.
I do not understand why it does not trigger on empty fields.. what if someone
wants to make a customcontrol that does several checks, including a required
check?
Anyway.. what i prefer is to get rid of the RequiredValidator and keep using
the CustomValidator.
Does anyone have any tips how to do either of these?
Kind regards, Eric.

Nov 17 '05 #1
1 1530
I found a post on google newsgroups by Bruce Barker.
You da man Bruce! :)
According to Bruce you can change WebUIValidation.js and modify
CustomValidatorEvaluateIsValid.

I did the following.

function CustomValidatorEvaluateIsValid(val)
{
var value = "";
if (typeof(val.controltovalidate) == "string")
{
value = ValidatorGetValue(val.controltovalidate);
// if (ValidatorTrim(value).length == 0)
// return true;
}

var args = { Value:value, IsValid:true };
if (typeof(val.clientvalidationfunction) == "string")
{
eval(val.clientvalidationfunction + "(val, args) ;");
}
return args.IsValid;
}
Works fine for me.
Eric B <no> wrote:

Hi,

I've made a serverside component that automatically adds a validator.
Currently i have both a REQUIRED validator and a CUSTOM validator in it.

The customValidator has a javascript function that checks the value and if the
value is bad it makes the control RED.
(All done client side)

My problem now is that i also want to do that with fields that are required.

So i have two options:

Extend the requiredvalidator somehow so it will also change the color of
controls.

or

Somehow get the CustomValidator to trigger when fields are empty.
I do not understand why it does not trigger on empty fields.. what if someone
wants to make a customcontrol that does several checks, including a required
check?
Anyway.. what i prefer is to get rid of the RequiredValidator and keep using
the CustomValidator.
Does anyone have any tips how to do either of these?
Kind regards, Eric.



Nov 17 '05 #2

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

Similar topics

1
by: Jaisabari | last post by:
How to save viewstate in Custom controls -- Regards Jaisabari
1
by: OhFiddleSticks | last post by:
Does anyone know if there is a way to add a text value to a combo box (the text box part, not the rowsource) in VBA without triggering an update event? I've tried everything I can think of without...
2
by: philipp | last post by:
Hi I want to write a customControl, which shows a login-component containing textboxes for the username and password and a login-button. As soon as a user logs in, the textboxes and the button...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
0
by: Angrez Singh | last post by:
Hi, I am trying to use a "customcontrol" inside a "webusercontrol" but facing problem with the viewstate of the "customcontrol". When I use the "customcontrol" on a page either adding it...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
7
by: christinamasalha | last post by:
hello all, I've been trying to figure this out for days but i don't know what the problem is. I have this form which contains 2 subforms on it. On one of the subforms there is a fields called...
5
by: Vincent | last post by:
I have a bound listbox control on one of my forms that has an associated afterupdate event. When this event is invoked, I lock the control to prevent the user from clicking on it more than once....
1
by: raddrummer | last post by:
OK this is a total newbie question but.....I have a field in a subform that I want to use to trigger an event on change(). I'm debugging and am trying to get a message box to fire on change (just to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.