开发者

changing validation group of button with javascript on client side

In a form I have multiple group of controls which are grouped using validation group property. I want to a开发者_如何学运维ssign 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";       
  }
}


function changeValidationGrop(){
    var _ddlStatus = document.getElementById("<%=ddl.ClientID%>");
    var _selectedIndex = _ddlStatus.selectedIndex;
    var btn = document.getElementById("<%=btnNext.ClientID%>");
    var newValGroup;
    if(_selectedIndex == 1)
         newValGroup="G1";
    else
         newValGroup="G2";
    btn.onclick = function(){
          WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnNext", "", true, newValGroup, "", false, false));                
    }           
}    

Still no documentation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜