adding Form Validation Javacript of jquery???

Posted by user634599 on Stack Overflow See other posts from Stack Overflow or by user634599
Published on 2011-02-28T22:14:40Z Indexed on 2011/02/28 23:25 UTC
Read the original article Hit count: 284

How can I add inline Validation to make sure a choice of radio input must be selected

<script type="text/javascript">
    function choosePage() {
        if(document.getElementById('weightloss').form1_option1.checked) {
            window.location.replace( "http://google.com/" );
        }
        if(document.getElementById('weightloss').form1_option2.checked) {
            window.location.replace( "http://yahoo.com/" );
        }
    }
</script>

<form id="weightloss">
     <input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan">
     <label for="form1_option1"> 5 Day - All Inclusive Price</label><br>
     <input type="radio" id="form1_option2" name="weight-loss" value="7_day">
     <label for="form1_option2"> 7 Day - All Inclusive Price</label><br>
     <input type="button" value="Place Order" alt="Submit button" class="orange_btn" onclick="choosePage()">
</form>

© Stack Overflow or respective owner

Related posts about form

Related posts about input