Problem with custom validator in asp.net
-
Hi, I am having one text box and two button named APPLY and START, and two custom validator, both i am validating in jquery. in one custom control i have given controlTovalidate to Textbox... for another custom control i haven't given any controltoValidate...mainly for validation on click of "Start" button... As per my knowledge both should be get tiggered.. but in one secnario like when the first custom validator args.isValid is true.. that time.. second Custom validator is not getting triggered... code of the first custom control
if (!promoCd.match(regEx))
// if promocode is not an integer of length 9 or 10 then return invalid
{$("#" + ClientId + "\_" + "spnPromoNotEnt").hide(); $("#" + ClientId + "\_" + "spnPromoNotReg").show(); args.IsValid = false; validateResult = false; } else { { args.IsValid = true; validateResult = true; $("#" + ClientId + "\_" + "spnPromoNotEnt").hide(); $("#" + ClientId + "\_" + "spnPromoNotReg").hide(); $("#TopMessagePanel").hide(); } }
when else part of the first custom code execute.. then second custom control not getting triggered
second custom validator code
function ValidatePromoCode(source, args) {
if (Response == null && validateResult == true) { if ($("#" + clientId + "\_txtPromo").val().length > 0) { args.IsValid = false; } } else if (validateResult != true) { $("#TopMessagePanel").hide(); }
}
thanks in advance
-
Hi, I am having one text box and two button named APPLY and START, and two custom validator, both i am validating in jquery. in one custom control i have given controlTovalidate to Textbox... for another custom control i haven't given any controltoValidate...mainly for validation on click of "Start" button... As per my knowledge both should be get tiggered.. but in one secnario like when the first custom validator args.isValid is true.. that time.. second Custom validator is not getting triggered... code of the first custom control
if (!promoCd.match(regEx))
// if promocode is not an integer of length 9 or 10 then return invalid
{$("#" + ClientId + "\_" + "spnPromoNotEnt").hide(); $("#" + ClientId + "\_" + "spnPromoNotReg").show(); args.IsValid = false; validateResult = false; } else { { args.IsValid = true; validateResult = true; $("#" + ClientId + "\_" + "spnPromoNotEnt").hide(); $("#" + ClientId + "\_" + "spnPromoNotReg").hide(); $("#TopMessagePanel").hide(); } }
when else part of the first custom code execute.. then second custom control not getting triggered
second custom validator code
function ValidatePromoCode(source, args) {
if (Response == null && validateResult == true) { if ($("#" + clientId + "\_txtPromo").val().length > 0) { args.IsValid = false; } } else if (validateResult != true) { $("#TopMessagePanel").hide(); }
}
thanks in advance
dayakar_dn wrote:
then second custom control not getting triggered
$("#" + ClientId + "_" + "spnPromoNotReg").hide(); Well first off, it's just a textbox, there's nothing custom about it. As far as triggering goes, it doesn't get triggered, JQuery has to be able to find that textbox in order to alter the visiblity of the textbox. If it can't find it, it won't get altered to hide. Check your spelling, or alter the way you declare the name of the textbox. args.IsValid I don't see the code or declaration for if (args.IsValid) == true { so I can't comment on it. If the condition is not met, the code will never execute.