file. I'm a little stuck as to how to handle the client-side validation for the customValidator (p.312), ValidatePhoneNumbers:
function ValidatePhoneNumbers(source, args)
var phoneHome = document.getElementById('<%= PhoneHome.ClientID %>');
var phoneBusiness = document.getElementById('<%= PhoneBusiness.ClientID %>');
if (phoneHome.value != '' || phoneBusiness.value != '')
args.IsValid = true;
args.IsValid = false;
This validation works perfect if left in the .acx file, but doesn't work if I move it to an external .js
In general, it seems that "<% %> " blocks are only allowed inside .aspx files. So I get an "Unable to get property value of an undefined or null reference" error on line, if (phoneHome.value != '' || phoneBusiness.value != '').
What is the best way to handle code with "<% %>" and move it to external .js
I guess one solution might be to change the ClientIDMode property for controls to static and then reference the control by id when using document.getElementById(''), but is this the recommended way?