How to use 1 submit button to validate user's input after selecting textbox, combobox

asp Mexico
  • 13 years ago

    hello, i need help in getting using one submit button to validate user's input afterr selecting between a textbox or combobox entry: here's my code:
    <table border="1" bgcolor="#b4beda" style="MARGIN-LEFT: 0px; WIDTH: 645px">
    <td><strong>Enter Security #</strong><input id="txtLpId" NAME="txtLpId" MAXLENGTH="5" TABINDEX ="1" style="WIDTH: 90px; HEIGHT: 20px; TEXT-ALIGN: left"></td>
    <td align="middle"><input style="FONT-WEIGHT: bolder; WIDTH: 74px; COLOR: white; HEIGHT: 24px; BACKGROUND-COLOR: #7e7ec9" type="submit" value="Submit" name="btnSubmit" id ="btnSubmit" onmouseover ="this.style.backgroundColor = '#be6572'" onmouseout="this.style.backgroundColor = '#7e7ec9'" onclick="return BtnSubmitValidation();" size=16></td>
    <td><strong>or Owner</strong>
    <td><SELECT id=cboGpOwner style="WIDTH: 96px" name=cboGpOwner">
    <OPTION value=0 selected> </OPTION>
    <OPTION value=1>AI</OPTION>
    <OPTION value=2>PAL</OPTION>
    <OPTION value=3>OTHER</OPTION>
    <OPTION value=4>UNKNOWN</OPTION></SELECT></td>
    <td align="middle"><input style="FONT-WEIGHT: bolder; WIDTH: 78px; COLOR: white; HEIGHT: 24px; BACKGROUND-COLOR: #7e7ec9" type="submit" value="Submit" name="btncboSubmit" id ="btncboSubmit" onmouseover ="this.style.backgroundColor = '#be6572'" onmouseout="this.style.backgroundColor = '#7e7ec9' "onclick="return cboGpOwnerValidation();"></td>
    <td align="middle"><input style="FONT-WEIGHT: bolder; WIDTH: 73px; COLOR: white; HEIGHT: 24px; BACKGROUND-COLOR: #7e7ec9" type="submit" value="Clear" name="btnClear" id ="btnClear" onmouseover="this.style.backgroundColor = '#be6572'" onmouseout="this.style.backgroundColor = '#7e7ec9'" size=12></td>
    <td align="middle width="0" height="0">
    <input id="Text1" NAME="txtClicked" MAXLENGTH="6" style="WIDTH: 0px; COLOR: #000000; HEIGHT: 0px; BACKGROUND-COLOR: #c9c9c9; TEXT-ALIGN: left" readonly></td>
    </tr></td>

  • 12 years ago

    I would rather do it like this.

     

    <
    script language="javascript">function BtnSubmitValidation()

    {

    var txtsercurity = document.getElementById("txtLpId").value;

    var cmbOwner = document.getElementById("cboGpOwner").value;

     

    if(txtsercurity = "" && cmbOwner="0")

    {

    alert(
    "Please enter Security # or select owner!")return false;

     

    }

     

    window.location.href=
    "confirm.asp";

    }

    </script>

    <body>

    <table border="1" bgcolor="#b4beda" style="MARGIN-LEFT: 0px; WIDTH: 335px">

    <td class="style1"><strong>Enter Security #</strong></td>

    <td><input id="txtLpId" NAME="txtLpId" MAXLENGTH="5" TABINDEX ="1" style="WIDTH: 90px; HEIGHT: 20px; TEXT-ALIGN: left">

    </td>

    </td>

    </tr><tr>

    <td ><strong>or Owner</strong></td>

    <td>

    <SELECT id=cboGpOwner style="WIDTH: 96px" name=cboGpOwner">

    <OPTION value=0 selected> </OPTION>

    <OPTION value=1>AI</OPTION>

    <OPTION value=2>PAL</OPTION>

    <OPTION value=3>OTHER</OPTION>

    <OPTION value=4>UNKNOWN</OPTION></SELECT></td>

    <tr>

    <td align="middle"><input style="FONT-WEIGHT: bolder; WIDTH: 78px; COLOR: white; HEIGHT: 24px; BACKGROUND-COLOR: #7e7ec9" type="submit" value="Submit" name="btncboSubmit" id ="btncboSubmit" onmouseover ="this.style.backgroundColor = '#be6572'" onmouseout="this.style.backgroundColor = '#7e7ec9' "onclick="return BtnSubmitValidation();"><input style="FONT-WEIGHT: bolder; WIDTH: 73px; COLOR: white; HEIGHT: 24px; BACKGROUND-COLOR: #7e7ec9" type="submit" value="Clear" name="btnClear" id ="btnClear" onmouseover="this.style.backgroundColor = '#be6572'" onmouseout="this.style.backgroundColor = '#7e7ec9'" size=12></td>

    <td align="middle">

    <input id="Text1" NAME="txtClicked" MAXLENGTH="6" style="WIDTH: 0px; COLOR: #000000; HEIGHT: 0px; BACKGROUND-COLOR: #c9c9c9; TEXT-ALIGN: left" readonly></td></tr></td>

     

     

     

    </body>

    </html>

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Engineers are all basically high-functioning autistics who have no idea how normal people do stuff.” - Cory Doctorow