changing validation group of button with javascript on client side

Posted by haansi on Stack Overflow See other posts from Stack Overflow or by haansi
Published on 2010-06-15T05:28:33Z Indexed on 2010/06/15 5:32 UTC
Read the original article Hit count: 226

Filed under:
|
|

hi,

In a form I have multiple group of controls which are grouped using validation group property. I want to assign validation group to asp.Button dynamically on client side using javascript on the base of item selected in drop down list.

Here is JavaScript which I am using, but it is not working. It shows validation group undefined but actually a default group is defined.

Please advice me. thanks

<script type="text/JavaScript">

function NextClicked() {  

  var _ddlStatus = document.getElementById("<%=ddl.ClientID%>");

  var _selectedIndex = _ddlStatus.selectedIndex;

  var _btn = document.getElementById("<%=btnNext.ClientID%>");


  alert(_btn.ValidationGroup); // here in messge it shows undefiend, yet I have defiend a group in button as default.  


  if (_selectedIndex == 1) {

    _btn.ValidationGroup = "G1";

  }

  else

    if (_selectedIndex == 2) {
      _btn.ValidationGroup = "G2";       
  }
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript