[Solved] accepting value from either of text boxes [closed]


The javascript validation method in your head tag:

function chkTxt(myForm)
{
  if(myForm.txt1.value == '' && myForm.txt2.value == '')
  {
    document.getElementById('msg').innerHTML = 'error';
    return false;
  }
  else
    return true;
}

You can set the onsubmit attribute of your form tag to call the method like this:

<form id="form1" runat="server" method="post" onsubmit="return chkTxt(this);">
    <div id="msg"></div>
    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
    <button type="submit">submit</button>
</form>

Just a simple example.

1

solved accepting value from either of text boxes [closed]