PHP: - 在newtab中通过POST验证并传递值

Below code is about passing the value to the new tab by POST.

My question is the value selected in drop-down list needed to be validated.

As 'select' value is default value. If the default value is selected then some alert must be shown else the remaining behavior is same as below code.

<form action="send_mail.php" name="choose_aff" method="POST">
<select name="company" id="company" class="company_select" style="width:250px;">
<option value="">Select</option>
<option value="abc">abc</option>
<option value="xyz">xyz</option>
</select>
<input class="proceed_btn" type="submit" value="Proceed to mail>>" style="float:right" onclick="this.form.target='_blank';return true;">
</form>

I remove a button and then the send_mail.php will open only when value is changed from dropdown. Add dropdown will send value using POST

<form action="send_mail.php" name="choose_aff" method="POST">
    <select name="company" id="company" class="company_select" style="width:250px;" onchange="submit()">
    <option value="">Select</option>
    <option value="abc">abc</option>
    <option value="xyz">xyz</option>
    </select>
    </form>

Add target="_blank" to form attributes like this

<form action="send_mail.php" name="choose_aff" method="POST" target="_blank">

You can validate without external libraries, just using javascript in client side (if you want) You need something like this:

<script type="text/javascript">
  function myValidateFunction() {
    alert("something happened!");
    console.log("something happened!");
    //what i want!
  }
</script>
...
<form action="send_mail.php" name="choose_aff" method="POST" target="_blank"> 
    <select name="company" id="company" class="company_select" style="width:250px;" onchange="myValidateFunction()">
        <option value="">Select</option>
        <option value="abc">abc</option>
        <option value="xyz">xyz</option>
    </select>
<input class="proceed_btn" type="submit" value="Proceed to mail" style="float:right;" />
</form>

Then you should validate the data sent in send_mail.php file