Results 1 to 1 of 1

Thread: Jquery selectbox validations

  1. #1
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default Jquery selectbox validations

    I have the following code working in Jquery.

    I need to display the message "Year Required" when the value or option value of select element is "0".
    My coding is as follows

    Code:
    <script type="text/javascript">
    $(document).ready(function () {
       $("#register").validate({
           
       debug: true,
           rules: {
              year: { required: function () { return ($("#year option:selected").val() == "0"); } }  
           },
    
           messages: {
               year: "Year Required",
           },
       });
    })
    </script>


    Select box coding


    Code:
    <select name="year"  id="year">
        <option value="0">Year</option>
        <option value="1">1919</option>
        <option value="2">1920</option>
        <option value="3">1921</option>
        <option value="4">1922</option>
    </select>
    For the above coding IE is not showing any errors. but the validations is not working. your suggestions shall be highly appreciated
    Last edited by james438; 02-15-2013 at 08:12 PM. Reason: please start using code tags.

Similar Threads

  1. geting value from chained selectbox
    By zodehala in forum PHP
    Replies: 0
    Last Post: 06-27-2010, 06:01 PM
  2. OnChange for selectbox
    By acctman in forum JavaScript
    Replies: 0
    Last Post: 07-08-2009, 12:42 AM
  3. Hide and Unhide a div with a selectbox
    By ramli66 in forum JavaScript
    Replies: 12
    Last Post: 11-18-2008, 07:05 PM
  4. Expand selectbox
    By molendijk in forum JavaScript
    Replies: 4
    Last Post: 03-25-2008, 11:20 AM
  5. Need help with multiple selectbox
    By peppetto in forum JavaScript
    Replies: 1
    Last Post: 05-11-2007, 06:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •