G
Guest
I'm trying to use a custom validator but it seems to trigger no matter what I
do. I'm not sure i'm referencing the controls involved correctly from the js.
My FormView is named fvRegDetail. I've tried both just the control name and
the formview name appended with the control name as I find it in the rendered
source.
function ClientValidateCommuteMethod(ctl, args)
{
var txt1 = document.getElementById ("fvRegDetail_tbDaysDriveAlone").value;
var txt2 = document.getElementById ("fvRegDetail_tbDaysVanPool").value;
var txt3 = document.getElementById ("fvRegDetail_tbDaysMARTABus").value;
var txt4 = document.getElementById ("fvRegDetail_tbDaysBicycle").value;
var txt5 = document.getElementById ("fvRegDetail_tbDaysTelework").value;
var txt6 = document.getElementById ("fvRegDetail_tbDaysCarpool").value;
var txt7 = document.getElementById ("fvRegDetail_tbDaysCCTBus").value;
var txt8 = document.getElementById ("fvRegDetail_tbMARTARail").value;
var txt9 = document.getElementById ("fvRegDetail_tbDaysWalk").value;
if (txt1.length > 0 ||
txt2.length > 0 ||
txt3.length > 0 ||
txt4.length > 0 ||
txt5.length > 0 ||
txt6.length > 0 ||
txt7.length > 0 ||
txt8.length > 0 ||
txt9.length > 0 ){
args.IsValid = true;
}else{
args.IsValid = false;
}
return args.IsValid;
}
My Custom Validator:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ClientValidateCommuteMethod"
ErrorMessage="Indicate a current commute method"
ValidationGroup="regForm"
OnServerValidate="CustomValidatorCommuteMethod_ServerValidate" >
Please indicate commute method - 1-7 days a week.
</asp:CustomValidator><br />
Thanks for any suggestions on this.
do. I'm not sure i'm referencing the controls involved correctly from the js.
My FormView is named fvRegDetail. I've tried both just the control name and
the formview name appended with the control name as I find it in the rendered
source.
function ClientValidateCommuteMethod(ctl, args)
{
var txt1 = document.getElementById ("fvRegDetail_tbDaysDriveAlone").value;
var txt2 = document.getElementById ("fvRegDetail_tbDaysVanPool").value;
var txt3 = document.getElementById ("fvRegDetail_tbDaysMARTABus").value;
var txt4 = document.getElementById ("fvRegDetail_tbDaysBicycle").value;
var txt5 = document.getElementById ("fvRegDetail_tbDaysTelework").value;
var txt6 = document.getElementById ("fvRegDetail_tbDaysCarpool").value;
var txt7 = document.getElementById ("fvRegDetail_tbDaysCCTBus").value;
var txt8 = document.getElementById ("fvRegDetail_tbMARTARail").value;
var txt9 = document.getElementById ("fvRegDetail_tbDaysWalk").value;
if (txt1.length > 0 ||
txt2.length > 0 ||
txt3.length > 0 ||
txt4.length > 0 ||
txt5.length > 0 ||
txt6.length > 0 ||
txt7.length > 0 ||
txt8.length > 0 ||
txt9.length > 0 ){
args.IsValid = true;
}else{
args.IsValid = false;
}
return args.IsValid;
}
My Custom Validator:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ClientValidateCommuteMethod"
ErrorMessage="Indicate a current commute method"
ValidationGroup="regForm"
OnServerValidate="CustomValidatorCommuteMethod_ServerValidate" >
Please indicate commute method - 1-7 days a week.
</asp:CustomValidator><br />
Thanks for any suggestions on this.