Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9038799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:34:30+00:00 2026-06-16T09:34:30+00:00

According to the accepted answer here this is what I have to do to

  • 0

According to the accepted answer here this is what I have to do to make required selects work with the validation.

I have created a sample on jsfiddle, but I can’t get it work.

The main difference is that my default is simply empty (“”).

<form id="myform">
    <select id="id_deals-0-currency" class="required" name="deals-0-currency">
    <option value="">---------</option>
    <option selected="selected" value="1">USD - $</option>
    <option value="2">EUR - €</option>
    </select>
</form>

$(function() {
    $(document).ready(function() {

        $.validator.addMethod("valueNotEquals", function(value, element, arg) {
            return arg != value;
        }, "Value must not equal arg.");


        $("#myform").validate({
            rules: {
                deals-0-currency: {
                    valueNotEquals: ""
                }
            },
            messages: {
                deals-0-currency: {
                    valueNotEquals: "Please select an item!"
                }
            }

        });
    });
})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:34:32+00:00Added an answer on June 16, 2026 at 9:34 am

    Your code works, with exception that you need to quote deals-0-currency as an object key and your empty string default is being trumped by the required class which makes the item required in validation. An empty value will trigger the required message first always and your validation method will never get triggered with current default of ""

    $("#myform").validate({           
        rules: {
            'deals-0-currency': {
                valueNotEquals: ""
            }
        },
        messages: {
            'deals-0-currency': {
                valueNotEquals: "Please select an item!"
            }
        }
    });
    

    DEMO ( with required class removed) http://jsfiddle.net/WGL4j/7/

    EDIT: To validate the select when it is changed use the validator valid() method which can be called on the whole form or individual elements only:

     $('#id_deals-0-currency').change(function(){
                $(this).valid()
    })
    

    Updated demo: http://jsfiddle.net/WGL4j/8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to MSDN here and here (as well as the accepted answer to this
Situation According to this accepted answer , if the " GC 'sees' a cyclic
I've edited RouMao's solution into my code sample below. according to the accepted answer
According to the comments in the accepted answer here Rails how to Gzip Javascript?
I have been looking around for this but couldn't find an answer anywhere, so
According to the accepted answer to this question GridView row height , if you...
I have not marked this question Answered yet. The current accepted answer got accepted
I thought MVC was supposed to make all this easier but I'm trying various
According to this answer , namespace-scoped static variables were undeprecated in C++11. That is,
I have run into a wall trying to find an answer to this question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.