0

Could anyone pleae figure out why this code is not working ? I can click submit button and go to next page without selecting anything. I want user to be allowed to go to next page only if the user selects any radio button. Thanks

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script>
<script type='text/javascript' src='http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js'></script>

  <script>
  $.noConflict();
  $(document).ready(function(){
    $("#form1").validate();
  });
  </script>

 <form method="post"  action="/action" id="form1" class="styled" enctype="multipart/form-data">
  <label for="name">1. Choose Category</label><br />
<select class="required" id="cat1" name="category">
                <option>select Category</option>

                    <option class="required" value="10">Cars</option>
                    <option class="required" value="8">House</option>
                    <option class="required" value="11">Mobiles</option>
                    <option class="required" value="3">Bus</option>
                    <option class="required" value="6">Services</option>
          </select>

        <input type="submit" name="buttonSubmit" value="Next Step"   class="btn-submit img-swap"  id="submit"  />
</form>
2
  • I might be wrong but it seems that the validation plugin requires jQuery 1.6.4+ and you are using v1.6.1, other than that your code seems to be fine. Commented Apr 6, 2013 at 6:01
  • I want user to be allowed to go to next page only if the user selects any radio button. there are no radio buttons in your code Commented Apr 6, 2013 at 6:17

1 Answer 1

1

From a quick view, your code seems to be fine but after a detailed view, the culprit is this html line :

<option>select Category</option>

... which also requires to have a(n) (empty) value attribute for the plugin to work properly, so it should look like :

<option value="">select Category</option>

... or much better :

<option selected="" value="" disabled="disabled">select Category</option>

See JSFIDDLE using jQuery v1.6.4, as in my previous comment

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.