Avatar of targetsoft

asked on 

Javascript never firing for CustomValidation

In my ASP.NET page, I have a custom validator and code for both server and client validation.
I also have several other validators on the form.  When I DON'T have the customvalidator, everything appears in my validation summary popup.
When I add the customvalidator, the summary does not appear and at least the field the customvalidator is working on does not get validated until post-back.  
It appears that the client side validation code is never firing (I added an alert to make sure), and the server code only validates on post-back (which is expected).
I need this to work like any other validator, and I think that once I get the javascript to fire, it'll be fine.
Below are my custom validator and the javascript.

<asp:CustomValidator runat="server" id="custIDType"
       ErrorMessage="Invalid ID Type">*</asp:CustomValidator>
<script language="JavaScript" type="text/javascript">
function clientCheckIDType(sender,args)
var actionTypeVal=document.getElementById("drpAction");
var idTypeVal = document.getElementById("drpIdType");
window.alert('I am JS');
if ((actionTypeVal.SelectedValue=="NEW") && (idTypeVal.SelectedValue !="PR" && idTypeVal.SelectedValue !="CMED" && idTypeVal.SelectedValue !="ERMS")) || (actionTypeVal.SelectedValue=="MOD" &&(idTypeVal.SelectedValue !="PR" && idTypeVal.SelectedValue !="CONTRACT")))
{ args.IsValid = false;
else {args.IsValid=true;}
// -->

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon