.net - jQuery addClass not adding class? -


i have checked forum not found solution works me. have simple .net page masterpage. trying implement validationgroup customvalidators, clientside validation.

the html straight forward (note, on of textboxes validating, test purposes only).

<div style="border: 1px solid #000; padding: 30px; margin-top: 100px;">    <asp:textbox id="txt1" runat="server" cssclass="form-control"></asp:textbox>    <asp:textbox id="txt2" runat="server" cssclass="form-control"></asp:textbox>    <asp:button id="btn1" runat="server" text="test a" cssclass="btn btn-primary" validationgroup="vgroup1" /> </div>  <asp:customvalidator id="cvtxt1" runat="server" validationgroup="vgroup1" controltovalidate="txt1" clientvalidationfunction="textvalidate" validateemptytext="true"></asp:customvalidator> 

the javascript straight forward well:

<script type="text/javascript"> function textvalidate(osrc, args) {     var isvalid = false;     // label label-warning     isvalid = args.value.trim();      if (isvalid) {          $("#" + osrc.controltovalidate).removeclass("has-error");         }     else {         $("#" + osrc.controltovalidate).addclass("has-error");     }      args.isvalid = isvalid; } </script> 

osrc.controltovalidate produces ctl00_contentplaceholder1_txt1 (and add # manually), correct id generated. but, class not updated?

update: when creating custom class called .test in head section, class added should be. so, cause .has-error not applied?

any ideas?

var isvalid = false; // label label-warning isvalid = args.value.trim();  if (isvalid) {      $("#" + osrc.controltovalidate).removeclass("has-error");     } else {     $("#" + osrc.controltovalidate).addclass("has-error"); } 

does line 'isvalid = args.value.trim();' need convert it's value boolean, true/false before passing if statement?


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -