P
Paolo Benetti
Dear all,
I'm trying to add a CustomValidator that must validate a TextBox, ensuring
that the number inserted be in a range of long.
I cannot use RangeValidator because long is not a supported type, and in
addition I wanted to learn to develop a Custom Validator control.
Everything worked fine until I tryied to add 2 different LongRangeValidator
controls on the same page, with 2 different ranges. The problem is that my
ClientValidationFunction is built at runtime with the range limits stamped
in it, that results in the following code rendered:
function ClientLongRangeValidation(source, arguments) {
arguments.IsValid = false;
if (!isNaN(arguments.Value)) {
var val = arguments.Value
if (arguments.Value >= -9223372036854775808 && arguments.Value <=
9223372036854775807)
arguments.IsValid = true;
}
}
I see that the normal RangeValidator control adds some interesting rows at
the bottom of the page:
var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
document.getElementById("gnIB1_ctl02");
gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
gnIB1_ctl02.type = "Integer";
gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
gnIB1_ctl02.maximumvalue = "2147483647";
gnIB1_ctl02.minimumvalue = "0";
While CustomValidator just adds the following:
var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
document.getElementById("gnIB2_ctl02");
gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
9223372036854775807";
gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";
It's seems that if I could add a minimumvalue and a maximumvalue fields for
each control, I could write a different client function that would work with
as many controls I'd like.
But how can I add "javascript fields"?
I see that CustomValidator inherits RegisterValidatorCommonScript and
RegisterValidatorDeclaration, but I don't think they're the right methods.
Any help would be appreciated, Thanks.
Paolo Benetti.
I'm trying to add a CustomValidator that must validate a TextBox, ensuring
that the number inserted be in a range of long.
I cannot use RangeValidator because long is not a supported type, and in
addition I wanted to learn to develop a Custom Validator control.
Everything worked fine until I tryied to add 2 different LongRangeValidator
controls on the same page, with 2 different ranges. The problem is that my
ClientValidationFunction is built at runtime with the range limits stamped
in it, that results in the following code rendered:
function ClientLongRangeValidation(source, arguments) {
arguments.IsValid = false;
if (!isNaN(arguments.Value)) {
var val = arguments.Value
if (arguments.Value >= -9223372036854775808 && arguments.Value <=
9223372036854775807)
arguments.IsValid = true;
}
}
I see that the normal RangeValidator control adds some interesting rows at
the bottom of the page:
var gnIB1_ctl02 = document.all ? document.all["gnIB1_ctl02"] :
document.getElementById("gnIB1_ctl02");
gnIB1_ctl02.controltovalidate = "gnIB1_gnTxt1";
gnIB1_ctl02.type = "Integer";
gnIB1_ctl02.evaluationfunction = "RangeValidatorEvaluateIsValid";
gnIB1_ctl02.maximumvalue = "2147483647";
gnIB1_ctl02.minimumvalue = "0";
While CustomValidator just adds the following:
var gnIB2_ctl02 = document.all ? document.all["gnIB2_ctl02"] :
document.getElementById("gnIB2_ctl02");
gnIB2_ctl02.controltovalidate = "gnIB2_gnTxt2";
gnIB2_ctl02.errormessage = "Invalid. Min:-9223372036854775808, max:
9223372036854775807";
gnIB2_ctl02.evaluationfunction = "CustomValidatorEvaluateIsValid";
gnIB2_ctl02.clientvalidationfunction = "ClientLongRangeValidation";
It's seems that if I could add a minimumvalue and a maximumvalue fields for
each control, I could write a different client function that would work with
as many controls I'd like.
But how can I add "javascript fields"?
I see that CustomValidator inherits RegisterValidatorCommonScript and
RegisterValidatorDeclaration, but I don't think they're the right methods.
Any help would be appreciated, Thanks.
Paolo Benetti.