javascript - Validation disappears on autopostback -


i validating control using javascript function. cannot use validators available in asp. s working fine when radio button postback rest of validation disappear. here validation code

 function validateform() {                 var validate = true;                          var summary = document.getelementbyid("<%=summary.clientid%>");                 if (summary.value == "") {                     summary.style.backgroundcolor = "yellow";                     validate = false;                 }                 if (validate == false) {                     alert('please fill highlighted fields');                 }                 return validate; 

here button code validate

<asp:button id="button1" runat="server" onclick="button1_click" text="submit" onclientclick="return validateform();" /> 

here radio button code

<asp:radiobutton id="submitter" text="submitter" groupname="rd2" runat="server" forecolor="black" oncheckedchanged="submitter_changed" autopostback="true" />                         <asp:radiobutton id="following" text="following" groupname="rd2" runat="server" forecolor="black" oncheckedchanged="following_changed" autopostback="true" /> 

i want color not change after autopostback. me please how it.

try using updatepanel this

 <asp:updatepanel id="updatepanel1" runat="server" updatemode="conditional">     <contenttemplate>         <asp:radiobutton id="submitter" text="submitter" groupname="rd2" runat="server" forecolor="black" oncheckedchanged="submitter_changed" autopostback="true" />         <asp:radiobutton id="following" text="following" groupname="rd2" runat="server" forecolor="black" oncheckedchanged="following_changed" autopostback="true" />    </contenttemplate>   </asp:updatepanel> 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -