[Solved] set up error message for drop down


Yes. You can acheive that with the combination of PHP and JQUERY

Let’s say this is your first page

<form action="secondPage.php" method="post">
    <select id="men" class="select_class1" name="subselector">
        <option value="">Choose an Item</option>
        <option value="tsm">T-Shirt</option>
        <option value="lsm">Long Sleeve</option>
        <option value="tankm">Tank Top</option>
    </select>
    <input type="submit" value="submit" />
</form>

Then this would be your secondPage.php

<?php
    $subselector = $_POST['subselector'];
?>
<form action="anotherPage.php" method="post">
    <select id="men" class="select_class1" name="subselector">
        <option value="">Choose an Item</option>
        <option value="tsm">T-Shirt</option>
        <option value="lsm">Long Sleeve</option>
        <option value="tankm">Tank Top</option>
    </select>
    <input type="submit" value="submit" />
</form>

<!-- Now using jQuery to prevent the form from submitting if only the previous selected value doesn't correspond with the present selected value -->
<!-- don't forget to include your jQuery library here -->

<script>
    $('form').submit(function(e){
        prevSelVal = "<?php echo $subselector; ?>";
        presentVal = $('select').val();
        if(prevSelVal !== presentVal){
            e.preventDefault();
            alert('Your Previous Selected Value must Correspond With Your Present Selected Value');
        }
    });
</script>

1

solved set up error message for drop down