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

  • Home
  • SEARCH
  • 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 9157833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:06:52+00:00 2026-06-17T13:06:52+00:00

Possible Duplicate: How to find index of object in a JavaScript array with jQuery

  • 0

Possible Duplicate:
How to find index of object in a JavaScript array with jQuery

I need to find value of input entered if already exists in .data() function.

I am trying this way.

jQuery

var array = $("form[name=update]").data("values", {"v1": "value1", "v2": "value2", "v3": "value3", "v4": "value4", "v5": "value5"});

if ($.inArray("value1", array) > -1){alert("duplicate value")}

But it does nothing.

Please see and suggest any possible way to do this.

Thanks.

  • 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-17T13:06:53+00:00Added an answer on June 17, 2026 at 1:06 pm

    Here

    grep (which does not do objects) did not work for me either.

    Here is a $.each version

    DEMO

    $(function() {
      $("form[name=update]").data("values", {"v1": "value11", "v2": "value2", "v3": "value3", "v4": "value4", "v5": "value5"});
      $(".but").on("click",function(e) {
        var fData = $("form[name=update]").data("values");
        var val = $(this).val();
          console.log(fData);
        $.each(fData, function(n,i) { 
            console.log("!!!",n,i)
          if (i===val) {
            alert("duplicate value");
            return false;
          }    
        })  
        e.preventDefault()  
      });
    });    
    

    This is now I had a look, the same method as danronmoon’s solution

    DEMO

    $(function() {
      $("form[name=update]").data("values", {"v1": "value11", "v2": "value2", "v3": "value3", "v4": "value4", "v5": "value5"});
      $(".but").on("click",function(e) {
        var fData = $("form[name=update]").data("values");
        var val = $(this).val();
          console.log(fData);
        for (var o in fData) { 
            console.log("!!!",o,fData[o])
          if (fData[o]===val) {
            alert("duplicate value");
            break;
          }    
        }  
        e.preventDefault()  
      });
    });    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Find object by id in an array of JavaScript objects How to
Possible Duplicate: Easiest way to find duplicate values in a JavaScript array Javascript array
Possible Duplicate: Pythonic way to find maximum value and its index in a list?
Possible Duplicate: indexOf method in an object array? I have a javascript array which
Possible Duplicate: Find length (size) of an array in jquery I have a json
Possible Duplicate: flash as3 - how do I find an object's index in an
Possible Duplicate: Find text string using jQuery? How do you find a text string
Possible Duplicate: Find and Replace more than 1 word? I want to use jQuery
Possible Duplicate: How to find the sizeof(a pointer pointing to an array) Sizeof array
Possible Duplicate: How to find a duplicate of length 5 in a single array.

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.